Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create list of files for mkdocs #130

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions spec_parser/mkdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,37 @@ def _generate_in_dir(dirname, group, tmplfname):
_generate_in_dir("Individuals", model.individuals, "individual.md.j2")
_generate_in_dir("Datatypes", model.datatypes, "datatype.md.j2")

def _gen_filelist(nsname, itemslist, heading):
ret = []
nameslist = [c.name for c in itemslist.values()]
if nameslist:
ret.append(f" - {heading}:")
for n in sorted(nameslist):
ret.append(f" - model/{nsname}/{heading}/{n}.md")
return ret

files = dict()
for ns in model.namespaces:
nsn = ns.name
files[nsn] = []
files[nsn].append(f" - {nsn}:")
files[nsn].append(f" - 'Description': model/{nsn}/{nsn}.md")
files[nsn].extend(_gen_filelist(nsn, ns.classes, "Classes"))
files[nsn].extend(_gen_filelist(nsn, ns.properties, "Properties"))
files[nsn].extend(_gen_filelist(nsn, ns.vocabularies, "Vocabularies"))
files[nsn].extend(_gen_filelist(nsn, ns.individuals, "Individuals"))
files[nsn].extend(_gen_filelist(nsn, ns.datatypes, "Datatypes"))

filelines = []
filelines.append('- model:')
# hardwired order of namespaces
for nsname in ["Core", "Software", "Security",
"Licensing", "SimpleLicensing", "ExpandedLicensing",
"Dataset", "AI", "Build", "Lite", "Extension"]:
filelines.extend(files[nsname])

fn = p / "mkdocs-files.yml"
fn.write_text("\n".join(filelines))

def class_link(name):
if name.startswith("/"):
Expand Down