bskinn / sphobjinv

Toolkit for manipulation and inspection of Sphinx objects.inv files
https://sphobjinv.readthedocs.io
MIT License
78 stars 9 forks source link

Q about use sphinx with sphinx.ext.autodoc`😃 #233

Closed kloczek closed 2 years ago

kloczek commented 2 years ago

Disclaimer: This ticket is not the issue report. It is just humble question 😃

I'm packaging as rpm packages python modules for some distribution. Already I've done almost 900 such packages. Part of the packaging goals is include sphinx based documentation as man pages if sphinx based documentation is provided. Such goal needs usually needs only small modyfications and at the moment I have almost 600 of all modules which have ocumentation in such form .. however I'm struggling in most of the cases when module source code needs to be scanned usually by autodoc sphinx extension. Usually what is missing is path to the module code. Usually such path is provided by lines like below in copy.py:

import sys
import os
sys.path.append(os.path.abspath('../../src'))

I just found that your module does not need typical modyfication in copy.py and all works (almost) flawlessly 😃

+ /usr/bin/sphinx-build -n -T -b man doc/source build/sphinx/man
Running Sphinx v4.5.0
making output directory... done
loading intersphinx inventory from https://docs.python.org/3/objects.inv...
loading intersphinx inventory from https://www.sphinx-doc.org/en/master/objects.inv...
building [mo]: targets for 0 po files that are out of date
building [man]: all manpages
updating environment: [new config] 24 added, 0 changed, 0 removed
reading sources... [100%] syntax
WARNING: Unexpected return code 1 from command Command(command=('sphobjinv', 'suggest', '-u', 'https://sphobjinv.readthedocs.io/en/v2.0rc1/cmdline.html', 'compress'), shell=False, hide_standard_error=False, working_directory='/home/tkloczko/rpmbuild/BUILD/sphobjinv-2.2.2/tests/resource') (output=' \nNo inventory at provided URL.\nAttempting "https://sphobjinv.readthedocs.io/en/v2.0rc1/cmdline.html/objects.inv" ...\nAttempting "https://sphobjinv.readthedocs.io/en/v2.0rc1/objects.inv" ...\nAttempting "https://sphobjinv.readthedocs.io/en/objects.inv" ...\nAttempting "https://sphobjinv.readthedocs.io/objects.inv" ...\n \nNo inventory found!')
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
writing... python-sphobjinv.3 { cli/index cli/convert cli/suggest api_usage customfile levenshtein syntax api/index api/data api/enum api/error api/fileops api/inventory api/re api/schema api/zlib cli/implementation/index cli/implementation/core cli/implementation/load cli/implementation/parser cli/implementation/paths cli/implementation/ui cli/implementation/write } done
build succeeded, 1 warning.

I cannot find find in your copy.py any traces of setting up path to the module and to be honest I'm puzzled a bit. May I ask for explaination how it is done? I'm asking because your solution seems does not need running sphinx-build in tox venv or does not need to heve module already installed or alter $PYTHONPATH. Looks like your module contains something whcih could be spread across all other modules, and I may try to spread simillar solution to other modules. 😄 Thx ..

kloczek commented 2 years ago

Closing .. I just found that accidentally I had installed sphobjinv in build env and this is why it was working :(

bskinn commented 2 years ago

Yep, the dev workflow for the project involves a pip install -e .. Without that, I would also need to patch sys.path in conf.py.

Sorry, no magic here! 🫤

kloczek commented 2 years ago

Yep, the dev workflow for the project involves a pip install -e .. Without that, I would also need to patch sys.path in conf.py.

pep517 build which I'm executing before generate documentation alredy adds to the tree module metadata so that step is not needed and without alter sys.path in conf.py build-sphinx does not work.