Skip to content

Commit

Permalink
MNT #879 downloads for vocabulary files
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Jun 18, 2022
1 parent a6102a6 commit f733bd4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions utils/nxdl2rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
repo_root_path = pathlib.Path(__file__).parent.parent
WRITE_ANCHOR_REGISTRY = False
HTML_ROOT = 'https://github.com/nexusformat/definitions/blob/main'
MANUAL_ROOT = "https://manual.nexusformat.org/classes/"
MANUAL_ROOT = "https://manual.nexusformat.org/"
SUBDIR_MAP = {
'base': 'base_classes',
'application': 'applications',
Expand Down Expand Up @@ -70,7 +70,7 @@ def add(self, anchor):
if anchor not in reg:
hanchor = self._html_anchor(anchor)
fnxdl = "/".join(pathlib.Path(self.nxdl_file).parts[-2:]).split(".")[0]
url = f"{MANUAL_ROOT}{self.category}/{fnxdl}.html{hanchor}"
url = f"{MANUAL_ROOT}classes/{self.category}/{fnxdl}.html{hanchor}"
reg[anchor] = dict(
term=anchor,
html=hanchor,
Expand Down Expand Up @@ -136,11 +136,19 @@ def _write_html(self, contents):
body = lxml.etree.SubElement(root, "body")
title = lxml.etree.SubElement(body, "h1")
subtitle = lxml.etree.SubElement(body, "em")
title.text = contents["_metadata"]["title"]
subtitle.text = contents["_metadata"]["subtitle"]

title.text = contents["_metadata"]["title"].strip(".")
subtitle.text = contents["_metadata"]["subtitle"].strip(".")
vocab_list = lxml.etree.SubElement(body, "h2")
vocab_list.text = "NXDL Vocabulary"

p = lxml.etree.SubElement(body, "p")
p.text = "This content is also available in these formats: "
for ext in "json txt yml".split():
a = lxml.etree.SubElement(p, "a")
a.attrib["href"] = f"{MANUAL_ROOT}_static/{self.txt_file.stem}.{ext}"
a.text = f" {ext}"

dl = lxml.etree.SubElement(body, "dl")
for term, termlist in sorted(contents["terms"].items()):
dterm = lxml.etree.SubElement(dl, "dt")
Expand Down

0 comments on commit f733bd4

Please sign in to comment.