Skip to content

Commit

Permalink
Updates to external docs handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidraker committed Oct 3, 2023
1 parent 24d489e commit 136c1c2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 42 deletions.
87 changes: 46 additions & 41 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,44 +62,49 @@
# epub_show_urls = 'footnote'


# script_dir = os.path.dirname(os.path.realpath(__file__))
# agent_docs_root = os.path.join(script_dir, "external-docs")
#
# # Custom event handlers for Volttron #
# def setup(app):
# """
# Registers callback method on sphinx events. callback method used to
# dynamically generate api-docs rst files which are then converted to html
# by readthedocs
# :param app:
# """
# # app.connect('builder-inited', generate_apidoc)
# app.connect('builder-inited', generate_agent_docs)
#
# # app.connect('build-finished', clean_api_rst)
# app.connect('build-finished', clean_agent_docs_rst)
#
#
# def generate_agent_docs(app):
# agent_name = 'volttron-bacnet-proxy'
# agent_repo = f'https://github.com/eclipse-volttron/{agent_name}'
# docs_source_dir = 'docs/source'
# agent_version = 'releases/0.2.0-rc'
# agent_clone_dir = os.path.join(agent_docs_root, agent_name)
#
# subprocess.check_call(["git", "clone", "--no-checkout", agent_repo], cwd=agent_docs_root)
# subprocess.check_call(["git", "sparse-checkout", "set", docs_source_dir], cwd=agent_clone_dir)
# subprocess.check_call(["git", "checkout", agent_version], cwd=agent_clone_dir)
#
# def clean_agent_docs_rst(app, exception):
# """
# Deletes folder containing all auto generated .rst files at the end of
# sphinx build immaterial of the exit state of sphinx build.
# :param app:
# :param exception:
# """
# global agent_docs_root
# import shutil
# if os.path.exists(agent_docs_root):
# print("Cleanup: Removing agent docs clone directory {}".format(agent_docs_root))
# shutil.rmtree(agent_docs_root)
script_dir = os.path.dirname(os.path.realpath(__file__))
external_docs_root = os.path.join(script_dir, "external-docs")

# Custom event handlers for Volttron #
def setup(app):
"""
Registers callback method on sphinx events. callback method used to
dynamically generate api-docs rst files which are then converted to html
by readthedocs
:param app:
"""
# app.connect('builder-inited', generate_apidoc)
app.connect('builder-inited', generate_agent_docs)

# app.connect('build-finished', clean_api_rst)
app.connect('build-finished', clean_agent_docs_rst)


def generate_agent_docs(app):
os.makedirs(external_docs_root)
project_name = agent_name= 'volttron-bacnet-proxy'
agent_repo = f'https://github.com/eclipse-volttron/{agent_name}'
docs_source_dir = 'docs/source'
agent_version = 'develop'
agent_clone_dir = os.path.join(external_docs_root, agent_name)
subprocess.check_call(["git", "clone", "--no-checkout", agent_repo, project_name + "_docs_root"],
cwd=external_docs_root)
# for 1st version not doing api-docs. If doing api-docs do full checkout, install requirements, run api-docs
clone_dir = os.path.join(external_docs_root, project_name + "_docs_root")
subprocess.check_call(["git", "sparse-checkout", "set", docs_source_dir], cwd=clone_dir)
subprocess.check_call(["git", "checkout", agent_version], cwd=clone_dir)
doc_index_dir = os.path.join(clone_dir, docs_source_dir)
os.symlink(doc_index_dir, os.path.join(external_docs_root, project_name))

def clean_agent_docs_rst(app, exception):
"""
Deletes folder containing all auto generated .rst files at the end of
sphinx build immaterial of the exit state of sphinx build.
:param app:
:param exception:
"""
global external_docs_root
import shutil
if os.path.exists(external_docs_root):
print("Cleanup: Removing agent docs clone directory {}".format(external_docs_root))
shutil.rmtree(external_docs_root)
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ in the volttron-lib-bacnet-driver repository.
.. toctree::
:hidden:

BACnet Proxy Agent <external-docs/volttron-bacnet-proxy/docs/source/index>
BACnet Proxy Agent <external-docs/volttron-bacnet-proxy/index>

0 comments on commit 136c1c2

Please sign in to comment.