mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Fix #2892: Added `-a (--append-syspath) option to sphinx-apidoc`
This commit is contained in:
@@ -107,6 +107,7 @@ Features added
|
|||||||
apidoc is run frequently.
|
apidoc is run frequently.
|
||||||
* #2851: `sphinx.ext.math` emits missing-reference event if equation not found
|
* #2851: `sphinx.ext.math` emits missing-reference event if equation not found
|
||||||
* #1210: ``eqref`` role now supports cross reference
|
* #1210: ``eqref`` role now supports cross reference
|
||||||
|
* #2892: Added ``-a`` (``--append-syspath``) option to `sphinx-apidoc`
|
||||||
|
|
||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|||||||
@@ -458,6 +458,10 @@ The :program:`sphinx-apidoc` script has several options:
|
|||||||
This option makes sphinx-apidoc put module documentation before submodule
|
This option makes sphinx-apidoc put module documentation before submodule
|
||||||
documentation.
|
documentation.
|
||||||
|
|
||||||
|
.. option:: -a
|
||||||
|
|
||||||
|
Append module_path to sys.path.
|
||||||
|
|
||||||
.. option:: -H project
|
.. option:: -H project
|
||||||
|
|
||||||
Sets the project name to put in generated files (see :confval:`project`).
|
Sets the project name to put in generated files (see :confval:`project`).
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ Options
|
|||||||
|
|
||||||
These options are used with ``-F``:
|
These options are used with ``-F``:
|
||||||
|
|
||||||
|
-a Append module_path to sys.path.
|
||||||
-H <project> Project name to put into the configuration.
|
-H <project> Project name to put into the configuration.
|
||||||
-A <author> Author name(s) to put into the configuration.
|
-A <author> Author name(s) to put into the configuration.
|
||||||
-V <version> Project version.
|
-V <version> Project version.
|
||||||
|
|||||||
@@ -299,6 +299,9 @@ Note: By default this script will not overwrite already created files.""")
|
|||||||
help='file suffix (default: rst)', default='rst')
|
help='file suffix (default: rst)', default='rst')
|
||||||
parser.add_option('-F', '--full', action='store_true', dest='full',
|
parser.add_option('-F', '--full', action='store_true', dest='full',
|
||||||
help='Generate a full project with sphinx-quickstart')
|
help='Generate a full project with sphinx-quickstart')
|
||||||
|
parser.add_option('-a', '--append-syspath', action='store_true',
|
||||||
|
dest='append_syspath',
|
||||||
|
help='Append module_path to sys.path, used when --full is given')
|
||||||
parser.add_option('-H', '--doc-project', action='store', dest='header',
|
parser.add_option('-H', '--doc-project', action='store', dest='header',
|
||||||
help='Project name (default: root module name)')
|
help='Project name (default: root module name)')
|
||||||
parser.add_option('-A', '--doc-author', action='store', dest='author',
|
parser.add_option('-A', '--doc-author', action='store', dest='author',
|
||||||
@@ -366,6 +369,8 @@ Note: By default this script will not overwrite already created files.""")
|
|||||||
mastertocmaxdepth = opts.maxdepth,
|
mastertocmaxdepth = opts.maxdepth,
|
||||||
mastertoctree = text,
|
mastertoctree = text,
|
||||||
language = 'en',
|
language = 'en',
|
||||||
|
module_path = rootpath,
|
||||||
|
append_syspath = opts.append_syspath,
|
||||||
)
|
)
|
||||||
if isinstance(opts.header, binary_type):
|
if isinstance(opts.header, binary_type):
|
||||||
d['project'] = d['project'].decode('utf-8')
|
d['project'] = d['project'].decode('utf-8')
|
||||||
|
|||||||
@@ -19,9 +19,19 @@
|
|||||||
# add these directories to sys.path here. If the directory is relative to the
|
# 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.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
#
|
#
|
||||||
|
{% if append_syspath -%}
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
sys.path.insert(0, u'{{ module_path }}')
|
||||||
|
{% else -%}
|
||||||
# import os
|
# import os
|
||||||
# import sys
|
# import sys
|
||||||
|
{% if module_path -%}
|
||||||
|
# sys.path.insert(0, u'{{ module_path }}')
|
||||||
|
{% else -%}
|
||||||
# sys.path.insert(0, os.path.abspath('.'))
|
# sys.path.insert(0, os.path.abspath('.'))
|
||||||
|
{% endif -%}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
# -- General configuration ------------------------------------------------
|
# -- General configuration ------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user