Skip to content

Commit

Permalink
Add autogeneration of documentation of equipment module
Browse files Browse the repository at this point in the history
  • Loading branch information
jjgomera committed Nov 9, 2018
1 parent fede871 commit 79bbc96
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ docs/lib.thread.rst
docs/lib.unidades.rst
docs/lib.utilities.rst

docs/equipment.*.rst

# Script propios
.script/
iapws
Expand Down
8 changes: 8 additions & 0 deletions docs/equipment.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
equipment package
=================

.. automodule:: equipment


.. toctree::
:maxdepth: 2
49 changes: 46 additions & 3 deletions docs/generateReferences.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# Generate the *-ref.rst files with list of references
"""Module autogeneration of documentation files. This script autogenerate the
lib.*.rst and equipment.*.rst files with the automodule schema
lib.? module
====================
.. automodule:: lib.?
:members:
:undoc-members:
:show-inheritance:
:member-order: bysource
.. include:: lib.*_ref.rst
Furthermore autogenerate the lib.*_ref.rst files with a list of bibliographic
references used in the module
"""

import glob
from os.path import basename, splitext

import lib
import equipment

total = []

all = lib.__all__
all = lib.__all__
# for mod in lib.EoS.__all__:
# all.append(".".join(mod.__name__.split(".")[1:]))

total = []
# library module autogeneration
for library in all:
if library in ["EoS", "mEoS"]:
continue
Expand All @@ -33,10 +55,12 @@
print(" :show-inheritance:", file=file)
print(" :member-order: bysource", file=file)

# Add the *-ref.rst file to lib.*.rst file if it's available
if hasattr(module, "__doi__") and module.__doi__:
print("", file=file)
print(".. include:: lib.%s_ref.rst" % library, file=file)

# Generate the *-ref.rst files with list of references
if hasattr(module, "__doi__") and module.__doi__:
with open("docs/lib.%s_ref.rst" % library, "w") as file:
print("References", file=file)
Expand All @@ -45,3 +69,22 @@
id = str(id)
print(".. [%s] %s; %s. %s" % (
id, rf["autor"], rf["title"], rf["ref"]), file=file)

# equipment module autogeneration
lst = glob.glob("./equipment/[!^UI|__]*.py")
for mod in lst:
library = splitext(basename(mod))[0]

__import__("equipment.%s" % library)
module = equipment.__getattribute__(library)

# Make equipment.rst schemas
with open("docs/equipment.%s.rst" % library, "w") as file:
print("equipment.%s module" % library, file=file)
print("="*(len(library)+10+7), file=file)
print("", file=file)
print(".. automodule:: equipment.%s" % library, file=file)
print(" :members:", file=file)
print(" :undoc-members:", file=file)
print(" :show-inheritance:", file=file)
print(" :member-order: bysource", file=file)
1 change: 1 addition & 0 deletions docs/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ API reference
.. toctree::
:maxdepth: 4

equipment
lib
tools

0 comments on commit 79bbc96

Please sign in to comment.