-
Notifications
You must be signed in to change notification settings - Fork 365
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
Fix pynest api generation for documentation using mock #1274
Conversation
Mock pynestkernel
Add exceptions file
remove some content in connect function, provide link to connection managment guide, add func link and minor formatting changes removed old connecton info, update syntax and fix formatting issues remove whitespace, rtd req, add topology module add py and cpp to ignore and update headings
we decided to put this on hold for two weeks, because other PRs handle similar Python issues... |
@terhorstd sorry, this is a little unclear to me: which PRs are these? Which Python issues? |
@Silmathoron The issue he's referring to is the failing check on Travis with Python 2.7 |
I just checked and it seems that the errors should be easy to fixed: mostly copyright header errors and maybe some other formatting errors that should be fixed automatically by using
|
Co-Authored-By: Tanguy Fardet <Silmathoron@users.noreply.github.com>
Wow, |
@Silmathoron I'm afraid my Python-fu is fairly limited - and looking at the code I am not really confident with what I would all need to change to test if simple inheritance would work. |
OK, I'll try to check it at some point in the week-end or next week. |
Pynest mock Python 2 compatibility
@Silmathoron During our 'docathon' thanks to @hakonsbm, we were able to solve the issues with Travis - could you take a look and approve this PR if there is nothing else we need? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Sorry I did not have time to look into it before in the end.
I'm wondering about the choice of always using the mocked kernel.
Otherwise, if possible I would generalize the use of references using the :func:`function_name
nomenclature in the .rst files
doc/conf.py
Outdated
@@ -31,20 +31,55 @@ | |||
import sys | |||
import os | |||
|
|||
# import sphinx_gallery |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line
|
||
# -- Mock pynestkernel ---------------------------------------------------- | ||
# The mock_kernel has to be imported after setting the correct sys paths. | ||
from mock_kernel import convert # noqa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use the proper kernel if the install is not done on RtD?
If this really is a feature, then remove following comment lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were thinking for consistency, just leaving the mock_kernel for non RtD builds too; it then allows the docs to build without a proper nest install - Not sure if that's a 'feature', but could be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I don't have any preference, but if we keep the mock_kernel for all builds, then comments should go away ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do :)
doc/conf.py
Outdated
@@ -218,8 +265,6 @@ def setup(app): | |||
] | |||
|
|||
# -- Options for readthedocs ---------------------------------------------- | |||
# on_rtd = os.environ.get('READTHEDOCS') == 'True' | |||
# if on_rtd: | |||
# html_theme = 'alabaster' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also remove these lines
`SLI <an-introduction-to-sli.md>`__ ,the old syntax of the function | ||
still works, while in `PyNEST <introduction-to-pynest.md>`__, the | ||
``Connect()`` function has been renamed to ``OneToOneConnect()``. | ||
`Connect()` function has been renamed to `OneToOneConnect()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for existing functions, it would be nice to use the proper form to link directly to the corresponding docstring
either through :func:`nest.Connect
or :func:`nest.lib.hl_api_connections.Connect
depending on whether or not the full path is necessary.
do this to all functions in the API if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For creating these links, I'd like to wait for another PR -- we have a script that can search through all function occurrences and replace with the proper format.
doc/ref_material/index.rst
Outdated
|
||
* The `Command Index <https://www.nest-simulator.org/helpindex/>`_ contains a list of all SLI and C++ related reference material. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove extra blank lines
@@ -522,7 +475,7 @@ def CGParse(xml_filename): | |||
generator cg. | |||
|
|||
The library to provide the parsing can be selected | |||
by CGSelectImplementation(). | |||
by :py:func:`.CGSelectImplementation`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, if this link works, use this format for all links in previous .rst files (not sure the initial :py
is actually necessary, is it?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I just compiled the docs on my computer without issues, except for the fact that sphinx_gallery
and sphinx_tabs
are necessary and crash the build if not there... we should either mention it somewhere or make sure that a partial docs build is still done even if they are not there.
Apart from that, I would think we should make the PyNEST API more easy to find (Reference material > PyNEST functions) does not quite cut it for me (it is usually one of the first thing I am looking for in a documentaion).
Finally, I the API, I would put the "helper functions" at the very end and add a
.. contents::
:local:
at the beginning
@Silmathoron Thanks for your input! I updated the pynest apis so they appear on the side bar, they have an internal toc and are rearranged. As for the sphinx_gallery and tabs - these should be listed in the requirements.txt file in doc/. (We still need to update this and the doc README) in a separate PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! thanks for the hard work 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work. I tested it and it works great. Just a few small comments.
doc/mock_kernel.py
Outdated
''' | ||
Mock pynestkernel.pyx into dummy python file. | ||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tripel double-quoted strings should be used for docstrings and a title is missing.
doc/mock_kernel.py
Outdated
|
||
|
||
def convert(infile): | ||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment above.
This PR provides a solution for the PyNEST api generation on readthedocs.
The problem: pynest apis do not work on readthedocs.
For sphinx to auto generate the apis (sphinx-autodoc) for the website, it requires a running instance of nest. If we try to include nest in the build on ReadtheDocs, it times out because of resource limitations.
The solution:
Mock nest
All the credit goes to @Silmathoron, who provided the scripts/code required to mock nest!
The PyNEST apis functions were cleaned up a bit then indexed, and referenced in the docs
See output here: https://nest-test.readthedocs.io/en/pynest_mock/ref_material/pynest_apis.html