Built API docs from the docstrings using Sphinx+autodocs#329
Built API docs from the docstrings using Sphinx+autodocs#329IgorTatarnikov merged 61 commits intobrainglobe:mainfrom
Conversation
…solete markdown file
… fetch_external.py
…cs build workflow
|
@adamltyson I have added docs only for brainglobe-atlasapi, for now. |
|
Thanks @thisisrick25. Do you need any feedback at this stage? Or shall we wait until all the repos are included in this PR? |
|
I am facing a problem @adamltyson. I can generate the docs in my local environment, but when I implement them in GA workflow, One way I have yet to try is to write a completely different workflow action independent of |
|
That action is maintained by us (https://github.com/neuroinformatics-unit/actions/tree/main/build_sphinx_docs), so if you can work out what needs to be changed, you're welcome to submit a PR. |
|
I will open a new issue @neuroinformatics-unit/actions edit: issue neuroinformatics-unit/actions#83 |
|
@adamltyson I want to point out that the docstring syntax is inconsistent in brainglobe-atlasapi (have not checked in other repos). I got this warning locally
I checked by fixing the syntax and can confirm it works as expected. Do we need the -W flag to build Sphinx doc for the API workflow? My conscience says yes, but it will take some time to fix the docstrings. I'm not very familiar with how pre-commit works, but I think it might be possible to create a hook with the numpydoc repo to check the docstring for numpydoc validation. This would be helpful in the future. |
|
Thanks @thisisrick25 - you make some good points here.
Indeed, this is expected (a consequence of BrainGlobe's "organic" growth) and would be nice to fix.
I agree.
I don't know either, but agree it should be possible, and would be helpful. To help keep things tidy and manageable, I would tackle each point in a separate PR, in the following order
Does that make sense, and would you have capacity to try (for this repo only)? |
|
@alessandrofelder Yes I will be happy to help. |
… restore previously commented out repositories
…pository fetching
|
I want to address a few more things:
|
|
- Script now iterates through api.rst files nested within tool documentation directories. - This aligns the generation process with the new documentation structure. - Simplifies the generated toctree path to a relative api reference. - Improves robustness by checking for the "API Reference" heading instead of a specific toctree path. - Removes the dependency on a separate source/api directory.
- The make_api_index.py script now generates API documentation into package-specific subdirectories. - Previously, all API documentation files were placed directly under source/api/. - This change organizes the generated .rst files into source/documentation/<package_name>/api.rst. - Improves the logical grouping and discoverability of API documentation for each package.
- Update .gitignore entries for Sphinx-generated API documentation. - Adjust paths to match the current output structure of the documentation build. - Ensure that generated API reference files are properly excluded from version control. - Prevents committing transient build artifacts. - Aligns with recent changes in the documentation generation process.
- The script now removes api.rst files and their corresponding api/ directories. - It updates the regex pattern for removing API toctree entries in index.md files. - This ensures a more comprehensive cleanup of generated API documentation artifacts. - Prevents stale or orphaned API documentation files from remaining after builds.
- Add comprehensive docstrings to fetch_repos.py for better script overview. - Improve inline comments across all API documentation generation scripts. - Enhance readability and maintainability of the documentation build process. - Provide clearer context for the logic involved in API documentation generation. - Correct a logging message in remove_api_toctrees.py for non-directory paths.
- Added detailed print statements to all documentation generation scripts. - Provides clearer feedback and progress indicators during the documentation build process. - Improves user experience by showing current steps and aiding in debugging. - Includes counts of processed repositories, API files, and packages. - Removed trailing newlines from several script files for consistency.
- Removed redundant if tool_dir.is_dir(): check from the main loop. - The tool_dirs list is already guaranteed to contain only directories. - Streamlines the script's logic and improves readability. - Eliminates an unused else branch for non-directory entries.
@IgorTatarnikov I have fixed the file structure, added some extra comments and print statements for better verbosity.
@adamltyson Unfortunately, no other repo other than Otherwise, this PR and brainglobe/brainglobe-atlasapi#584 are good to go. |
IgorTatarnikov
left a comment
There was a problem hiding this comment.
Looks good! Now that brainglobe/brainglobe-atlasapi#584 is merged we should be good to merge this once the list of packages is restricted.
- restrict this list to just brainglobe-atlasapi
|
Only |
|
Perfect, to avoid trying to resolve an environment where all packages required for atlas packing are present it might be best to not generate API docs for the atlas_generation scripts. I'll track this in brainglobe/brainglobe-atlasapi#624, once this is resolved, this PR can be merged as well. |
|
I've done some final local testing, now that brainglobe/brainglobe-atlasapi#624 is merged, we need to add Also, I'm seeing quite a few warnings thrown specifically for Class docstrings:
I'm also seeing a duplicate method section in the class docs:
I was able to fix both of these issues by adding |
|
Also, some of the E.g. in |
- Added a new attributes block to the class.rst autosummary template. - This block automatically lists public attributes of classes. - Attributes not starting with an underscore (_) are included. - Improves the completeness and discoverability of API documentation for classes.
Turns out these warnings happened because both I also added a new attributes section in the class template because |
This should be addressed in a new issue at |
IgorTatarnikov
left a comment
There was a problem hiding this comment.
Looks good on my end, I've tested it again with a local build. LGTM 🎉



Introduce a script to fetch external repositories for the Brainglobe project, update Sphinx configuration for improved documentation paths and extensions, and enhance the API documentation for the brainglobe-atlasapi module. Include setup instructions for Python and external packages in the Sphinx build workflow.
closes #4