I have a project B thats needs project A to work, so I'd like to embed documentation of A in the one of B, and, this document must be pdf (not html).
The project A looks like :
~> more conf.py
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = 'projectA'
copyright = '2021, JD'
author = 'JD'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc'
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
~> more .index.rst
.. projectA documentation master file, created by
sphinx-quickstart on Tue Jan 12 11:43:30 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to projectA's documentation!
====================================
.. toctree::
:maxdepth: 2
:caption: Contents:
projectA
~> more .projectA.py
#!/usr/bin/python
"""This is the documentation of project A."""
class classA:
"""This the class A."""
def methodA(self, who):
"""This is stuff that A does."""
return
~> more .projectA.rst
project A
=========
.. automodule:: projectA
.. autoclass:: classA
.. automethod:: methodA
The documentation of A is created without any problem.
The project B is at the same level than projectA and is the same than projectA replacing A with B.
~> tree -d
intersphinx_example
|_projectA
|_projectB
But now, B wants to use intersphinx to include documentation of A into it's own documentation.
~/projectB> git diff
diff --git a/conf.py b/conf.py
index 0a22df8..ac641cf 100644
--- a/conf.py
+++ b/conf.py
@@ -28,9 +28,14 @@ author = 'JD'
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
+ 'sphinx.ext.intersphinx',
'sphinx.ext.autodoc'
]
+intersphinx_mapping = {
+ 'projA': (os.path.join('..', 'projectA'), None),
+}
+
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
diff --git a/projectB.py b/projectB.py
index b057498..b42d485 100644
--- a/projectB.py
+++ b/projectB.py
@@ -1,10 +1,16 @@
#!/usr/bin/python
-"""This is the documentation of project B."""
+"""This is the documentation of project B: projectB needs :ref:`projA`."""
+
+import os
+import sys
+sys.path.append(os.path.join(os.getcwd(), '..', 'projectA'))
+from projectA import classA
class classB:
"""This the class B."""
def methodB(self, who):
- """This is stuff that B does."""
+ """This is stuff that B does: B need to use :ref:`projA.classA` """
+ a = classA()
return
Generating the documentation in projectB does not work. There are at least 3 problems :
intersphinx inventory '..projectA/objects.inv' not fetchable : there is no objects.inv in projectA, how to get it ?
projectB.py:docstring of projectB:1: WARNING: undefined label: proja
projectBprojectB.py:docstring of projectB.classB.methodB:1: WARNING: undefined label: proja.classa
The documentation I aim to get is pdf. The projects (A and B) are python code on HD (no web) and have no html associated documentation.
Is this kind of stuff (generating nested pdf documentation) possible with intersphinx ? Out of scope of it ?
UPDATE
Does not work either (with axect same erros) with:
~projectB> git diff
diff --git a/conf.py b/conf.py
index 0a22df8..bc99c77 100644
--- a/conf.py
+++ b/conf.py
@@ -28,9 +28,14 @@ author = 'JD'
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
+ 'sphinx.ext.intersphinx',
'sphinx.ext.autodoc'
]
+intersphinx_mapping = {
+ 'projA': (os.path.join('..', 'projectA', '_build'), None)
+}
+