0

I am using Sphinx to generate the documentation in python. While make html is working just fine, I have problems with make latexpdf. The .tex file is generated incompletely. It is missing some descriptions, which are included in html. I don't see where could be the problem? For instance, Calendar class is not showed in latex:

Latex [1]: https://i.stack.imgur.com/XVJYg.png HTML [2]: https://i.stack.imgur.com/4daHV.png

The conf.py I am using:

import os
import sys
sys.path.insert(0, os.path.abspath('../../src'))
sys.setrecursionlimit(1500)
project = '..'
copyright = '..'
author = '..'
release = '2.0'
extensions = ['rinoh.frontend.sphinx', 'sphinx.ext.autodoc']
exclude_patterns = []
html_theme = 'alabaster'
html_static_path = ['_static']

dialogs.rst:

GUI Dialogs
===========
Login
------
.. automodule:: dialogs.login
   :members:
   :undoc-members:
   :show-inheritance:
Calendar
--------
.. automodule:: dialogs.calendar
   :members:
   :undoc-members:
   :show-inheritance:

UPDATE There are several warnings which appear when using make latexpdf. I don't know if they are the cause. For the calendar module and any other module, the warning is like this one:

WARNING: Explicit markup ends without a blank line; unexpected unindent.
WARNING: autodoc: failed to import module 'calendar' from module 'dialogs'; the following exception was raised:
 File "c:\users\user\pycharmprojects\gui\venv\lib\site-packages\sphinx\ext\autodoc\importer.py", line 70, in import_module
    return importlib.import_module(modname)
...
    data_loaded = threading.Event()
NameError: name 'threading' is not defined

It looks like it cannot recognise the threading library.

prody
  • 194
  • 1
  • 11
  • What version of Python do you use? You should be more generous with blank lines for example before headings such as "Calendar". See https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html?highlight=blank#explicit-markup, – mzjn Aug 30 '21 at 13:32
  • I am using Python3.7, adding more blank lines doesn't help – prody Aug 31 '21 at 05:49
  • OK. But at least "WARNING: Explicit markup ends without a blank line; unexpected unindent" should be seen also when generating HTML. Are you using `threading` in your own code? Where is the line `data_loaded = threading.Event()`? – mzjn Aug 31 '21 at 07:45
  • Yes, these warnings are for HTML too. Inside calendar.py there is imported another module which uses `threading`. – prody Aug 31 '21 at 07:53
  • 1
    I cannot explain why there is a difference between HTML and LaTeX generation. I think a proper [mcve] is needed. – mzjn Aug 31 '21 at 08:00
  • I was trying to build a minimal reproducible example and I observed that `threading` is not imported in that module directly, but through a chain of `from ... import *`. I added `import threading` and now it works.. – prody Aug 31 '21 at 10:38

1 Answers1

1

You need to follow the advice of the errors and add white space and blank lines. Also make sure that underlines match the length of their headings.

I like to add two blank lines before the next section for readability, but only one is required. It is also not required to have a blank line after a section heading, but again I prefer its readability.

GUI Dialogs
===========


Login
-----

.. automodule:: dialogs.login
   :members:
   :undoc-members:
   :show-inheritance:


Calendar
--------

.. automodule:: dialogs.calendar
   :members:
   :undoc-members:
   :show-inheritance:
Steve Piercy
  • 13,693
  • 1
  • 44
  • 57