Spaces:
Sleeping
Sleeping
File size: 1,765 Bytes
d8d14f1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | import yaml
def update_mkdocs(
class_names,
base_path="docs/zeta/nn/modules",
mkdocs_file="mkdocs.yml",
):
"""
Update the mkdocs.yml file with new documentation links.
Args:
- class_names: A list of class names for which documentation is generated.
- base_path: The base path where documentation Markdown files are stored.
- mkdocs_file: The path to the mkdocs.yml file.
"""
with open(mkdocs_file) as file:
mkdocs_config = yaml.safe_load(file)
# Find or create the 'zeta.nn.modules' section in 'nav'
zeta_modules_section = None
for section in mkdocs_config.get("nav", []):
if "zeta.nn.modules" in section:
zeta_modules_section = section["zeta.nn.modules"]
break
if zeta_modules_section is None:
zeta_modules_section = {}
mkdocs_config["nav"].append(
{"zeta.nn.modules": zeta_modules_section}
)
# Add the documentation paths to the 'zeta.nn.modules' section
for class_name in class_names:
doc_path = f"{base_path}/{class_name.lower()}.md"
zeta_modules_section[class_name] = doc_path
# Write the updated content back to mkdocs.yml
with open(mkdocs_file, "w") as file:
yaml.safe_dump(mkdocs_config, file, sort_keys=False)
# Example usage
classes = [
"DenseBlock",
"HighwayLayer",
"MultiScaleBlock",
"FeedbackBlock",
"DualPathBlock",
"RecursiveBlock",
"PytorchGELUTanh",
"NewGELUActivation",
"GELUActivation",
"FastGELUActivation",
"QuickGELUActivation",
"ClippedGELUActivation",
"AccurateGELUActivation",
"MishActivation",
"LinearActivation",
"LaplaceActivation",
"ReLUSquaredActivation",
]
update_mkdocs(classes)
|