@@ -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
7683def 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
95103def 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
116160if __name__ == "__main__" :
0 commit comments