mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
Docs 202109 (#1067)
* module docstrings * db schema graph * dev docs first pass * dev docs pass 2 * add generated notification to top of generated docs files * linting * regen docs Co-authored-by: Stefan Pratter <stefan@20c.com> Co-authored-by: Sunshine Buchholz <sunshine@20c.com>
This commit is contained in:
62
peeringdb_server/gendocs.py
Normal file
62
peeringdb_server/gendocs.py
Normal file
@@ -0,0 +1,62 @@
|
||||
import datetime
|
||||
import importlib
|
||||
import os
|
||||
|
||||
import django
|
||||
|
||||
django.setup()
|
||||
|
||||
from pymdgen import doc_module
|
||||
|
||||
module_index = {}
|
||||
command_index = {}
|
||||
|
||||
now = datetime.datetime.now()
|
||||
|
||||
for entry in os.scandir("peeringdb_server"):
|
||||
if entry.name == "__init__.py":
|
||||
continue
|
||||
if entry.name[0] == ".":
|
||||
continue
|
||||
if entry.is_file and entry.name.find(".py") > -1:
|
||||
outfile = f"docs/dev/modules/{entry.name}.md"
|
||||
print(f"Generating {outfile}")
|
||||
with open(outfile, "w") as fh:
|
||||
doc_text = doc_module(f"peeringdb_server/{entry.name}", section_level=1)
|
||||
fh.write(f"Generated from {entry.name} on {now}\n\n")
|
||||
fh.write("\n".join(doc_text))
|
||||
|
||||
try:
|
||||
module_index[entry.name] = doc_text[2]
|
||||
except IndexError:
|
||||
continue
|
||||
|
||||
for entry in os.scandir("peeringdb_server/management/commands"):
|
||||
if entry.name == "__init__.py":
|
||||
continue
|
||||
if entry.name[0] == ".":
|
||||
continue
|
||||
if entry.is_file and entry.name.find(".py") > -1:
|
||||
try:
|
||||
doc_text = doc_module(
|
||||
f"peeringdb_server/management/commands/{entry.name}", section_level=1
|
||||
)
|
||||
command_index[entry.name] = doc_text[2]
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
with open("docs/dev/modules.md", "w") as fh:
|
||||
mod_names = sorted(module_index.keys())
|
||||
fh.write(f"Generated on {now}\n\n")
|
||||
for mod in mod_names:
|
||||
descr = module_index.get(mod)
|
||||
fh.write(f"## [{mod}](/docs/dev/modules/{mod}.md)\n\n")
|
||||
fh.write(f"{descr}\n\n")
|
||||
|
||||
with open("docs/dev/commands.md", "w") as fh:
|
||||
mod_names = sorted(command_index.keys())
|
||||
fh.write(f"Generated on {now}\n\n")
|
||||
for mod in mod_names:
|
||||
descr = command_index.get(mod)
|
||||
fh.write(f"## {mod}\n\n")
|
||||
fh.write(f"{descr}\n\n")
|
Reference in New Issue
Block a user