Skip to content
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

Simplify and improve template #8

Merged

Conversation

jcfr
Copy link
Contributor

@jcfr jcfr commented May 19, 2019

This PR implements the following:

  • simpler maintenance of the template by making use of nwb-docutils to generate the documentation.
  • addition of the following post generation hooks:
    • creation of extension spec executing script create_extension_spec.py
    • initialization of git repository

@jcfr jcfr force-pushed the nwb-docutil-as-postgen-hook-to-generate-docs branch 2 times, most recently from b19009a to 014182f Compare May 19, 2019 00:49
@jcfr jcfr force-pushed the nwb-docutil-as-postgen-hook-to-generate-docs branch from 014182f to 22152a0 Compare May 19, 2019 00:51
@jcfr jcfr requested review from rly and oruebel May 19, 2019 00:52
jcfr added 6 commits May 19, 2019 02:04
Since a git repo is required to successfully build the documentation, this
is done here.
  [...]
  Creating file /tmp/simulation_output/spec/simulation_output.extensions.yaml with 1 data types
  Creating file /tmp/simulation_output/spec/simulation_output.namespace.yaml
  [...]
Previous example has been copied from the simulation_output extension
and was causing warnings when attempting to build the documentation.

Indeed, the "Compartments" type was undefined.
@jcfr jcfr changed the title Simplify template maintenance generating docs using nwb-docutils Simplify and improve template May 19, 2019
@jcfr jcfr force-pushed the nwb-docutil-as-postgen-hook-to-generate-docs branch from 3e8fa2b to 384c488 Compare May 19, 2019 06:51
@jcfr jcfr force-pushed the nwb-docutil-as-postgen-hook-to-generate-docs branch from 68592d6 to e2bd453 Compare May 19, 2019 08:41
This commit ensures the "spec/*.yaml" files are copied to "src/pynwb/spec/*.yaml",
doing so allows the file to be packages into the distributed wheel.

It also removes the setting of "include_package_data=True" from the
NEXTSTEP instructions, spec files are already packages by setting package_data.
@jcfr jcfr force-pushed the nwb-docutil-as-postgen-hook-to-generate-docs branch from e2bd453 to 188b62d Compare May 19, 2019 08:45
Copy link
Contributor

@oruebel oruebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than running the init_sphinx_extension_docs script I think we could just make the files it creates part of the cookiecutter and remove the init_sphinx_extension_docs.

jcfr added 2 commits May 19, 2019 04:54
This commit ensures the extension python package is named after the
namespace. Doing so avoids to override file like "pynwb/__init__.py"
provided by the upstream "pynwb" package.
@jcfr
Copy link
Contributor Author

jcfr commented May 19, 2019

Rather than running the init_sphinx_extension_docs script I think we could just make the files it creates part of the cookiecutter and remove the init_sphinx_extension_docs.

Do you think the original reasons leading to the implementation of init_sphinx_extension_docs are not valid anymore ? (it allows a fair amount of customization)

EDIT: To follow up, since nwb-docutils should be moved to a nwb agnostic location (see hdmf-dev/hdmf#7), removing init_sphinx_extension_docs from it is more relevant.

Fix python package layout to avoid overriding pynwb installation

To avoid overriding the files from the upstream pynwb package, the ndx python extension package must have a dedicated name.

Indeed, since we can't have pynwb/__init__.py, this last commit updates the template so that we have the following in the source tree:

<root>/src/pynwb/ndx_my_extension/__init__.py
<root>/spec/*.yaml

windows failure

These are due to using a folder name {{ cookiecutter.namespace|replace("-", "_") }}, I will implement a fix later tomorrow.

@jcfr
Copy link
Contributor Author

jcfr commented May 19, 2019

Once, this last failure is addressed ... the remaining feature to implement will be the use of an entrypoints allowing to automatically register the ndx python extension on installation and allows any of the following:

  • listing installed extensions using a pynwb functions (e.g pnwb.list_registered_namespaces())
  • automatic loading of registered namespace on import. Do we want that ? @oruebel
  • implement a function named pynwb.load_registered_namespaces()

@jcfr jcfr force-pushed the nwb-docutil-as-postgen-hook-to-generate-docs branch from 0159762 to 1c490cf Compare May 19, 2019 09:28
@jcfr jcfr merged commit 7c99eac into nwb-extensions:master May 19, 2019
@jcfr jcfr deleted the nwb-docutil-as-postgen-hook-to-generate-docs branch May 19, 2019 09:32
@rly
Copy link
Contributor

rly commented May 23, 2019

Rather than running the init_sphinx_extension_docs script I think we could just make the files it creates part of the cookiecutter and remove the init_sphinx_extension_docs.

Do you think the original reasons leading to the implementation of init_sphinx_extension_docs are not valid anymore ? (it allows a fair amount of customization)

EDIT: To follow up, since nwb-docutils should be moved to a nwb agnostic location (see hdmf-dev/hdmf#7), removing init_sphinx_extension_docs from it is more relevant.

@oruebel Should we remove init_sphinx_extension_docs and make it part of the cookiecutter then? Sorry @jcfr I know you spent a lot of time on this...

@oruebel
Copy link
Contributor

oruebel commented May 23, 2019

@oruebel @jcfr whatever makes most sense to you with regard to the init_sphinx_extensions_docs is fine with me. If it is useful or easier to keep using the script then that's fine with me too. I just thought it would make things simpler to just have it part of the cookiecutter.

@jcfr
Copy link
Contributor Author

jcfr commented May 23, 2019

Should we remove init_sphinx_extension_docs and make it part of the cookiecutter then?

It could be added to the hooks module here: https://github.com/nwb-extensions/ndx-template/tree/master/hooks

But if we don't anticipate the user running the CLI locally to update their documentation, we could simply get ride of it.

To get ride of it suggest the following step:

  • generate an extension using cookie cutter
  • update the cookie cutter
  • re-generate and compare using tool like meld

Since I already have a local script to support that workflow, I could fairly quickly update ndx-template so that we eliminate init_sphinx_extensions_docs. Let me know

@rly
Copy link
Contributor

rly commented May 23, 2019

OK. Yeah, I think we should replace init_sphinx_extensions_docs with cookiecutter template files. It seems a little easier to maintain the cookiecutter template than the init_sphinx_extensions_docs script. e.g. helpful IDE features such as syntax coloring and Markdown previews do not work on the strings of Python/Markdown code within init_sphinx_extensions_docs. It is also a little easier to see and debug what cookiecutter is doing than the python script.

While the init_sphinx_extensions_docs does allow for some extra customization at the command line, I don't think that customization will ever be used.

@jcfr It would be great if you could make this change. Let me know if you would like a hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants