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

Auto-generate API files #131

Merged
merged 3 commits into from Apr 25, 2019
Merged

Auto-generate API files #131

merged 3 commits into from Apr 25, 2019

Conversation

weaverba137
Copy link
Member

This PR closes #130, providing a mechanism to auto-generate Sphinx API files.

Examples:

  • Generate doc/api.rst from scratch: python setup.py api
  • Overwrite an existing doc/api.rst file: python setup.py api --overwrite
  • Generate a new api file to compare with an existing file: python setup.py api --api doc/new_api.rst

I've tested this on desiutil itself, where it generated a document byte-for-byte identical to the existing api file, and also on desispec, where it found only minor differences.

@sbailey
Copy link
Contributor

sbailey commented Apr 25, 2019

Nice!

How hard would it be to either add this as a pre-runner to "python setup.py build_sphinx", or otherwise add another command that would effectively be "python setup.py api --overwrite && python setup.py build_sphinx" and we would start using that instead of "build_sphinx"?

i.e. this is so nice at auto-generating the API, is there any reason why we wouldn't want to automatically do that instead of requiring us to remember to run "python setup.py api --overwrite" occasionally to make sure our api.rst is up-to-date? Or maybe include it in travis tests to flag if api.rst is out of date?

OK to merge as-is if these extensions are non-trivial, but otherwise this looks so good I'd like to automate its use if possible instead of requiring us to remember to use it.

@weaverba137
Copy link
Member Author

I don't think we always want to automatically overwrite the doc/api.rst, which is why I included --overwrite and related options:

  • Some API files may contain custom titles, text, or other metadata. The desispec api.rst file does.
  • In a handful of cases, we might want not to include certain auto-detected modules. For example, desispec/pipeline/attic/workers.py.

@weaverba137
Copy link
Member Author

I actually did replace the python setup.py test command in the past, and that was somewhat painful. I think the best practice is to run this as a check when tagging a new version, or when adding several new modules. Or to just generate the file for the first time for a brand-new package.

@sbailey
Copy link
Contributor

sbailey commented Apr 25, 2019

OK, sounds good. Thanks for the followup explanations. Merging now.

@sbailey sbailey merged commit 23c8729 into master Apr 25, 2019
@sbailey sbailey deleted the auto-api branch April 25, 2019 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autogenerate api.rst
2 participants