Skip to content

Commit b8bb388

Browse files
committed
Modified the navigation bar to be consistent with plotly.py docs
1 parent 24ba085 commit b8bb388

File tree

167 files changed

+91072
-100241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+91072
-100241
lines changed

bin/generate_reference_pages.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
import os
22
from pathlib import Path
3+
import mkdocs_gen_files
34

4-
def generate_pages(path, output_dir, parent):
5+
def generate_pages(path, output_dir, parent, nav=None):
56
with os.scandir(path) as it:
6-
for folder in it:
7+
entries = sorted(it, key= lambda e: e.name)
8+
for folder in entries:
79
dir_name = folder.name + ".md"
810
# print(dir_name)
911
# Make md file storing its snippet
1012
file_path = os.path.join(output_dir, dir_name)
13+
# print(file_path)
1114

1215
with open(file_path, 'w') as f:
1316
f.write(f'# {folder.name}\n')
1417
f.write(f'--8<-- \"{parent}/{folder.name}/index.html\"\n')
1518

19+
# Add to navigation
20+
if nav is not None:
21+
nav[(folder.name)] = dir_name
22+
1623
it.close()
1724

25+
nav = mkdocs_gen_files.Nav()
26+
1827
# Walk through the docs/tmp/ directory and generate .md files that include the html snippets in it
1928
parent = Path(__file__).resolve().parents[1]
2029
ref_path = f"{parent}/docs/tmp/reference"
@@ -27,6 +36,8 @@ def generate_pages(path, output_dir, parent):
2736
os.makedirs(ref_output_dir, exist_ok=True)
2837
os.makedirs(examples_output_dir, exist_ok=True)
2938

30-
generate_pages(ref_path, ref_output_dir, "reference")
39+
generate_pages(ref_path, ref_output_dir, "reference", nav)
3140
generate_pages(examples_path, examples_output_dir, "javascript")
3241

42+
with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
43+
nav_file.writelines(nav.build_literate_nav())

0 commit comments

Comments
 (0)