Skip to content

Commit

Permalink
Add partial nav generator
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Dec 29, 2020
1 parent bcb363a commit 7d4f511
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
52 changes: 52 additions & 0 deletions api/documentation/gen-nav.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
""" Generate a YAML representation of a directory structure for mkdocs nav config
mkocs nav Docs: https://www.mkdocs.org/user-guide/writing-your-docs/#file-layout
Inpsire by: https://github.com/mkdocs/mkdocs/issues/714#issuecomment-626226113
"""

import yaml
import os
from pprint import pprint

################################################################################
# Configuration
################################################################################
mkdocs_config_file = "mkdocs.yml"


################################################################################
# Helper Functions
################################################################################
def dir_to_dict(path):
directory = {}
for dirname, dirnames, filenames in os.walk(path):
dn = os.path.basename(dirname)
directory[dn] = []

if dirnames:
for d in dirnames:
directory[dn].append(dir_to_dict(path=os.path.join(path, d)))
for f in filenames:
directory[dn].append(f)
else:
directory[dn] = filenames

return directory



################################################################################
# Script
################################################################################

if __name__ == "__main__":

rootdir = './docs'
dir_tree = dir_to_dict(rootdir)
yaml_dir_tree = yaml.dump(dir_tree)
print(yaml_dir_tree)

# with open(mkdocs_config_file) as config_file:
# mkdocs_config = yaml.full_load(config_file)

# with open(mkdocs_config_file, "w") as config_file:
# config_dump = yaml.dump(mkdocs_config, config_file)
66 changes: 66 additions & 0 deletions api/documentation/mkdocs.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
################################################################################
# mkdocs Settings
# See: https://www.mkdocs.org/user-guide/configuration/
################################################################################

site_name: webqueue2 API
repo_url: https://github.itap.purdue.edu/ECN/webqueue2
plugins:
- search
markdown_extensions:
- toc:
permalink: ⚓︎
- admonition
- pymdownx.details
- pymdownx.superfences
- pymdownx.highlight:
use_pygments: false
- pymdownx.inlinehilite
- pymdownx.tabbed
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
- mkautodoc



################################################################################
# Material for mkdocs Settings
# See: https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/
################################################################################

# TODO: Implement offline search
# See: https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-search/#offline-search
# TODO: Implement versioning
# See: https://squidfunk.github.io/mkdocs-material/setup/setting-up-versioning/#versioning

theme:
name: material
palette:
# Used to toggle dark mode.
# scheme: slate
primary: deep purple
accent: teal
icon:
logo: material/book-open
# The favicon is symlinked from the ReactJS public folder
favicon: images/favicon.ico
features:
- navigation.sections

extra:
social:
- icon: fontawesome/brands/slack
link: https://purdueecn.slack.com/archives/C019K7PSPNW
name: webqueue2 on Slack
- icon: fontawesome/brands/github
link: https://github.itap.purdue.edu/ECN/webqueue2
name: webqueue2 on GitHub

extra_javascript:
- https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js
- javascript/highlight.js
- https://cdnjs.cloudflare.com/ajax/libs/tablesort/5.2.1/tablesort.min.js
- javascript/tablesort.js
extra_css:
- https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/default.min.css

0 comments on commit 7d4f511

Please sign in to comment.