I am working on documenting a piece of code using ReadTheDocs (RTD). Here is the GitHub repo that it builds off, and below it is the current state of the website:
Repo: https://github.com/GluonicPenguin/AutoDQM
RTD: https://autodqm.readthedocs.io/en/latest/index.html
I have run a Sphinx-build locally and checked the build on RTD, and I get no warnings or errors, but the autodqm/dqm.py
module does not display the list of functions properly on RTD, i.e. the lists of functions aren't appearing. I had an issue with autodqm/compare_hists.py
as well, and I found the issue was I had an import ROOT
line at the top (with the other import lines), which when the import is called through a ROOT() function, for some reason this cures the issue and the autodqm/compare_hists.py
module displays properly on the website.
I thought a similar fix would work with autodqm/dqm.py
but in this case, I have to define near the top the functions
def lxml():
import lxml.html
return lxml.html
def FuturesSession():
from requests_futures.sessions import FuturesSession
return FuturesSession
and I have to remove the class DQMSession. At most I can think that RTD doesn't like handling import functions of the form import <package>.<subpackage>
.
I also apologise in advance for all the commits and vague/poor commit messages - I was doing this exhaustively, and developing this locally rather than on GitHub, so I had to keep pushing to test this.
Is there a reason why the setup I currently have doesn't work? Are there other issues that I'm missing? I've never used Sphinx/RTD before, so I'm a novice when it comes to fixing things like this. The reason why I'm not wanting to support the quick fix above with "segregated" import functions is this code needs to be efficient given it is designed to scan through a lot of histograms to perform stats comparisons on, which on that scale efficiency is essential.
Based on Steve's response above, I fixed the issue in AutoDQM RE failing to import modules, so now all the functions display properly on the website. The fixes were:
dqm.py - requests-futures and lxml now requirements specified in setup.py, which are pip installed via
install_requires=['lxml==4.5.2','requests-futures==1.0.0']
compare_hists.py - import ROOT fixed using extension autodoc_mock_imports from autodoc, so there is a line in docs/conf.py autodoc_mock_imports = ["ROOT"]. We need the requirement like this because it is a package with C dependencies, so can't be pip installed like the others.
Thanks for your help!