Skip to content

Commit

Permalink
[docs] improve teros integration
Browse files Browse the repository at this point in the history
  • Loading branch information
sjkelly committed Jul 23, 2021
1 parent e533063 commit 2ea26e7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
_build/
internals.rst
4 changes: 1 addition & 3 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ help:
teros-%:
mkdir -p $(TEROS_PATH)
teroshdl-hdl-documenter --recursive -i ../src/ -o html --outpath $(TEROS_PATH)
cp $(TEROS_PATH)/index.html teros.html
mkdir -p $(TEROS_PATH)/../$*/doc_internal
cp $(TEROS_PATH)/doc_internal/* $(TEROS_PATH)/../$*/doc_internal
python3 teros_sphinx_wrap.py $(TEROS_PATH)/doc_internal ./internals.rst


# Catch-all target: route all unknown targets to Sphinx using the new
Expand Down
6 changes: 0 additions & 6 deletions docs/internals.rst

This file was deleted.

25 changes: 25 additions & 0 deletions docs/teros_sphinx_wrap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3

#
# Load TerosHDL (Colbiri) outputs into a sectioned RST file for integration with Sphinx
#
# python3 teros_sphinx_wrap.py <docs_internal path> <output rst>
#
# example:
# python3 teros_sphinx_wrap.py ./_build/teroshdl/doc_internal ./internals.rst

import sys, os

#.. raw:: html
# :file: teros.html
if (os.path.isdir(sys.argv[1]) and len(sys.argv) == 3 and sys.argv[2] != ""):
internal_files = os.listdir(sys.argv[1])
with open(sys.argv[2], 'w') as output:
output.write("===============\nVerilog Modules\n===============\n\n")
for file in internal_files:
mod_name = os.path.splitext(file)[0]
html_path = os.path.join(sys.argv[1], file)
section_header = '-'*len(mod_name)+'\n'
output.write(f"{section_header}{mod_name}\n{section_header}\n.. raw:: html\n :file: {html_path}\n\n")
else:
print("python3 teros_sphinx_wrap.py <docs_internal path> <output rst>")

0 comments on commit 2ea26e7

Please sign in to comment.