Skip to content

Commit e1e411e

Browse files
Add sidebar label in the docs page sidebar. (#128)
This cleans up the sidebar as preparation for adding more docs' links there.
1 parent 0a0e29c commit e1e411e

File tree

8 files changed

+67
-15
lines changed

8 files changed

+67
-15
lines changed

docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
sidebar_position: 1
3+
sidebar_label: Docs
34
---
45

56
<!--
@@ -15,3 +16,4 @@ This directory contains information about how the project works, goals, and comm
1516
- [code_of_conduct.md](./code_of_conduct.md): The Beman Project's code of conduct.
1617
- [faq.md](./faq.md): Frequently asked questions about the Beman Project.
1718
- [governance.md](./governance.md): The governance document outlines the structure of the Beman Project.
19+
- [mission.md](./mission.md): The mission statement of the Beman Project.

docs/beman_library_maturity_model.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
sidebar_position: 2
3+
sidebar_label: Beman Library Maturity Model
34
---
45

56
<!--

docs/beman_standard.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
sidebar_position: 3
3+
sidebar_label: Beman Standard
34
---
45

56
<!--

docs/code_of_conduct.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
sidebar_position: 7
3+
sidebar_label: Code of Conduct
34
---
45

56
<!--

docs/faq.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
sidebar_position: 5
3+
sidebar_label: FAQ
34
---
45

56
<!--

docs/governance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
sidebar_position: 6
3+
sidebar_label: Governance
34
---
45

56
<!--

docs/mission.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
sidebar_position: 4
3+
sidebar_label: Mission
34
---
45

56
<!--

scripts/sync-docs.py

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,37 @@ def copy_images(beman_repo_path: Path, website_repo_path: Path):
5555
shutil.copytree(beman_images_path, target_directory)
5656

5757

58-
def insert_sidebar_position(file_path: Path, sidebar_position: int):
58+
def insert_sidebar_metadata(file_path: Path, sidebar_position: int, sidebar_label: str):
5959
"""
6060
Insert the sidebar position into the file.
61-
Literally insert 3 lines at the top of the file:
61+
Literally insert 3 (or 4) lines at the top of the file:
6262
---
6363
sidebar_position: {sidebar_position}
64+
sidebar_label: {sidebar_label}
6465
---
6566
"""
6667
with open(file_path, "r") as file:
6768
lines = file.readlines()
68-
lines.insert(0, f"---\n")
69-
lines.insert(1, f"sidebar_position: {sidebar_position}\n")
70-
lines.insert(2, f"---\n")
71-
lines.insert(3, f"\n")
69+
prefix = [
70+
f"---\n",
71+
f"sidebar_position: {sidebar_position}\n",
72+
]
73+
if sidebar_label:
74+
prefix.append(f"sidebar_label: {sidebar_label}\n")
75+
else:
76+
raise ValueError(f"No side label provided for {file_path}")
77+
prefix.append(f"---\n")
78+
prefix.append(f"\n")
7279
with open(file_path, "w") as file:
73-
file.writelines(lines)
80+
file.writelines(prefix + lines)
7481

7582

7683
def sync_beman_docs(
7784
beman_repo_path: Path,
7885
website_repo_path: Path,
7986
relative_path: str,
8087
sidebar_position: int,
88+
sidebar_label: str = "",
8189
):
8290
"""
8391
Copy beman/{relative_path} to /docs/{relative_path} for website build.
@@ -89,7 +97,7 @@ def sync_beman_docs(
8997
shutil.copy(beman_path, website_path)
9098

9199
print(f"Inserting sidebar position {sidebar_position} into {website_path}")
92-
insert_sidebar_position(website_path, sidebar_position)
100+
insert_sidebar_metadata(website_path, sidebar_position, sidebar_label=sidebar_label)
93101

94102

95103
def main():
@@ -102,15 +110,51 @@ def main():
102110
website_repo_path = Path(__file__).parent.parent
103111

104112
copy_images(beman_repo_path, website_repo_path)
105-
sync_beman_docs(beman_repo_path, website_repo_path, "docs/README.md", 1)
106113
sync_beman_docs(
107-
beman_repo_path, website_repo_path, "docs/beman_library_maturity_model.md", 2
114+
beman_repo_path,
115+
website_repo_path,
116+
"docs/README.md",
117+
1,
118+
sidebar_label="Docs",
119+
)
120+
sync_beman_docs(
121+
beman_repo_path,
122+
website_repo_path,
123+
"docs/beman_library_maturity_model.md",
124+
2,
125+
sidebar_label="Beman Library Maturity Model",
126+
)
127+
sync_beman_docs(
128+
beman_repo_path,
129+
website_repo_path,
130+
"docs/beman_standard.md",
131+
3,
132+
sidebar_label="Beman Standard",
133+
)
134+
sync_beman_docs(
135+
beman_repo_path,
136+
website_repo_path,
137+
"docs/mission.md",
138+
4,
139+
sidebar_label="Mission",
140+
)
141+
sync_beman_docs(
142+
beman_repo_path, website_repo_path, "docs/faq.md", 5, sidebar_label="FAQ"
143+
)
144+
sync_beman_docs(
145+
beman_repo_path,
146+
website_repo_path,
147+
"docs/governance.md",
148+
6,
149+
sidebar_label="Governance",
150+
)
151+
sync_beman_docs(
152+
beman_repo_path,
153+
website_repo_path,
154+
"docs/code_of_conduct.md",
155+
7,
156+
sidebar_label="Code of Conduct",
108157
)
109-
sync_beman_docs(beman_repo_path, website_repo_path, "docs/beman_standard.md", 3)
110-
sync_beman_docs(beman_repo_path, website_repo_path, "docs/mission.md", 4)
111-
sync_beman_docs(beman_repo_path, website_repo_path, "docs/faq.md", 5)
112-
sync_beman_docs(beman_repo_path, website_repo_path, "docs/governance.md", 6)
113-
sync_beman_docs(beman_repo_path, website_repo_path, "docs/code_of_conduct.md", 7)
114158

115159

116160
if __name__ == "__main__":

0 commit comments

Comments
 (0)