Last active
February 18, 2018 07:20
-
-
Save pavan538/88cb3a44299c5a78cdcc17db94828788 to your computer and use it in GitHub Desktop.
Sphinx tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sphinx-quickstart | |
In conf.py add the path of the project as follows | |
sys.path.insert(0, os.path.abspath('/home/pavan/code/kafka_project')) | |
# to generate rst files from modules, use the following command | |
$ sphinx-apidoc -o build_docs/api/ -f /home/pavan/code/kafka_project/framework | |
To build the module use the following command in root_directory of sphinx where conf.py, static and templates files are included. | |
$ sphinx-build . _build/ | |
# By default sphinx wont create docstring for class constructor. we need to explicitly add the following in conf.py | |
autoclass_content = 'both' | |
# By default docstring generated for methods are sorted by aplhabetical. if we need to change to exactly how methods are defined, | |
we need to use the following in conf.py | |
autodoc_member_order = 'bysource' | |
# Add the below line in conf.py for cross reference warnings | |
class PatchedPythonDomain(PythonDomain): | |
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode): | |
if 'refspecific' in node: | |
del node['refspecific'] | |
return super(PatchedPythonDomain, self).resolve_xref( | |
env, fromdocname, builder, typ, target, node, contnode) | |
def setup(sphinx): | |
sphinx.override_domain(PatchedPythonDomain) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment