Skip to content

Commit 565f7e2

Browse files
authored
Merge pull request #252 from mfesiem/master
Add documentation with Sphinx and publish it to Read The Docs.
2 parents 0a19c7e + 2458c92 commit 565f7e2

22 files changed

+600
-129
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ _trial_temp/
1010
apidocs/
1111
*.egg-info
1212
.eggs
13+
docs/source/help.txt

CONTRIBUTING.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
What can you do
3+
---------------
4+
5+
If you like the project and think you could help with making it better, there are many ways you can do it:
6+
7+
- Create a new issue for new feature proposal or a bug
8+
- Triage old issues that needs a refresh
9+
- Implement existing issues (there are quite some of them, choose whatever you like)
10+
- Help with improving the documentation (We still have work to do!)
11+
- Spread a word about the project to your colleagues, friends, blogs or any other channels
12+
- Any other things you could imagine
13+
14+
Any contribution would be of great help and I will highly appreciate it! If you have any questions, please create a new issue.
15+
16+
.. Releasing a new package
17+
-----------------------
18+
19+
Releasing a new version is done via GitHub Actions.
20+
First commit the version update to master and wait for tests to pass.
21+
Create a tag on local branch and then push it::
22+
23+
git tag 1.2.3
24+
git push --tags

README.rst

Lines changed: 20 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,80 @@
11
pydoctor
2-
========
2+
--------
33

44
.. image:: https://travis-ci.org/twisted/pydoctor.svg?branch=tox-travis-2
55
:target: https://travis-ci.org/twisted/pydoctor
66

77
.. image:: https://codecov.io/gh/twisted/pydoctor/branch/master/graph/badge.svg
88
:target: https://codecov.io/gh/twisted/pydoctor
99

10+
.. image:: https://img.shields.io/badge/-documentation-blue
11+
:target: https://pydoctor.readthedocs.io/
12+
1013
This is *pydoctor*, an API documentation generator that works by
1114
static analysis.
1215

13-
It was written primarily to replace epydoc for the purposes of the
14-
Twisted project as epydoc has difficulties with zope.interface.
15-
If you are looking for a successor to epydoc after moving to Python 3,
16-
pydoctor might be the right tool for your project as well.
16+
It was written primarily to replace ``epydoc`` for the purposes of the
17+
Twisted project as ``epydoc`` has difficulties with ``zope.interface``.
18+
If you are looking for a successor to ``epydoc`` after moving to Python 3,
19+
``pydoctor`` might be the right tool for your project as well.
1720

18-
pydoctor puts a fair bit of effort into resolving imports and
21+
``pydoctor`` puts a fair bit of effort into resolving imports and
1922
computing inheritance hierarchies and, as it aims at documenting
20-
Twisted, knows about zope.interface's declaration API and can present
23+
Twisted, knows about ``zope.interface``'s declaration API and can present
2124
information about which classes implement which interface, and vice
2225
versa.
2326

2427
.. contents:: Contents:
2528

2629

27-
Usage
28-
-----
30+
Simple Usage
31+
~~~~~~~~~~~~
2932

3033
You can run pydoctor on your project like this::
3134

3235
$ pydoctor --make-html --html-output=docs/api --add-package=src/mylib
3336

34-
You can see the full list of options using ``pydoctor --help``.
37+
For more info, `Read The Docs <https://pydoctor.readthedocs.io/>`_.
3538

3639
Markup
37-
------
40+
~~~~~~
3841

3942
pydoctor currently supports the following markup languages in docstrings:
4043

4144
`epytext`__ (default)
4245
The markup language of epydoc.
4346
Simple and compact.
4447

45-
`reStructuredText`__
48+
`restructuredtext`__
4649
The markup language used by Sphinx.
4750
More expressive than epytext, but also slighly more complex and verbose.
4851

49-
plain text
52+
plaintext
5053
Text without any markup.
5154

5255
__ http://epydoc.sourceforge.net/manual-epytext.html
5356
__ https://docutils.sourceforge.io/rst.html
5457

5558
You can select a different format using the ``--docformat`` option.
5659

57-
Sphinx Integration
58-
------------------
59-
60-
Sphinx object inventories can be used to create deep links between API
61-
documentation generated by pydoctor and by Sphinx.
62-
63-
Linking to external API docs
64-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65-
66-
To link to the Python standard library documentation, add this to your
67-
pydoctor command line::
68-
69-
--intersphinx=https://docs.python.org/3/objects.inv
70-
71-
You can pass this option multiple times to also link to other libraries
72-
that provide a Sphinx objects inventory.
73-
74-
Linking to your API docs
75-
~~~~~~~~~~~~~~~~~~~~~~~~
76-
77-
pydoctor's HTML generator will also generate a Sphinx objects inventory
78-
using the following mapping:
79-
80-
* packages, modules -> py:mod:
81-
* classes -> py:class:
82-
* functions -> py:func:
83-
* methods -> py:meth:
84-
* attributes -> py:attr:
85-
86-
To use this mapping in Sphinx, configure the `intersphinx extension`__::
87-
88-
intersphinx_mapping = {
89-
'pydoctor': ('http://domain.tld/api', None),
90-
}
91-
92-
__ https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html
93-
94-
And use external references::
95-
96-
:py:func:`External API <pydoctor:pydoctor.model.Documentable.reparent>`
97-
98-
:py:mod:`pydoctor:pydoctor`
99-
:py:mod:`pydoctor:pydoctor.model`
100-
:py:func:`pydoctor:pydoctor.driver.getparser`
101-
:py:class:`pydoctor:pydoctor.model.Documentable`
102-
:py:meth:`pydoctor:pydoctor.model.Documentable.reparent`
103-
:py:attr:`pydoctor:pydoctor.model.Documentable.kind`
104-
10560
What's New?
106-
-----------
61+
~~~~~~~~~~~
10762

10863
pydoctor 20.7.2
109-
~~~~~~~~~~~~~~~
64+
^^^^^^^^^^^^^^^
11065

11166
* Fix handling of external links in reStructuredText under Python 3
11267
* Fix reporting of errors in reStructuredText under Python 3
11368
* Restore syntax highlighting of Python code blocks
11469

11570
pydoctor 20.7.1
116-
~~~~~~~~~~~~~~~
71+
^^^^^^^^^^^^^^^
11772

11873
* Fix cross-reference links to builtin types in standard library
11974
* Fix and improve error message printed for unknown fields
12075

12176
pydoctor 20.7.0
122-
~~~~~~~~~~~~~~~
77+
^^^^^^^^^^^^^^^
12378

12479
* Python 3 support
12580
* Type annotations on attributes are supported when running on Python 3
@@ -135,13 +90,3 @@ pydoctor 20.7.0
13590
This will be the last major release to support Python 2.7 and 3.5: future major releases will require Python 3.6 or later.
13691

13792
.. description-end
138-
139-
Releasing a new package
140-
-----------------------
141-
142-
Releasing a new version is done via Travis-CI.
143-
First commit the version update to master and wait for tests to pass.
144-
Create a tag on local branch and then push it::
145-
146-
git tag 1.2.3
147-
git push --tags

doc/fieldlist.txt

Lines changed: 0 additions & 33 deletions
This file was deleted.

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/conf.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = 'pydoctor'
21+
copyright = '2020, Michael Hudson-Doyle and various contributors (see Git history)'
22+
author = 'Michael Hudson-Doyle and various contributors (see Git history)'
23+
24+
from pydoctor._version import __version__
25+
version = __version__.short()
26+
27+
# -- General configuration ---------------------------------------------------
28+
29+
# Add any Sphinx extension module names here, as strings. They can be
30+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
31+
# ones.
32+
extensions = [
33+
"sphinx_rtd_theme", "sphinx.ext.intersphinx"
34+
]
35+
36+
# Add any paths that contain templates here, relative to this directory.
37+
templates_path = ['_templates']
38+
39+
# List of patterns, relative to source directory, that match files and
40+
# directories to ignore when looking for source files.
41+
# This pattern also affects html_static_path and html_extra_path.
42+
exclude_patterns = []
43+
44+
# Configure intersphinx magic
45+
intersphinx_mapping = {
46+
'pydoctor': ('https://pydoctor.readthedocs.io/api/', None),
47+
'twisted': ('https://twistedmatrix.com/documents/current/api/', None),
48+
}
49+
50+
# -- Options for HTML output -------------------------------------------------
51+
52+
# The theme to use for HTML and HTML Help pages. See the documentation for
53+
# a list of builtin themes.
54+
#
55+
html_theme = "sphinx_rtd_theme"
56+
57+
# Add any paths that contain custom static files (such as style sheets) here,
58+
# relative to this directory. They are copied after the builtin static files,
59+
# so a file named "default.css" will overwrite the builtin "default.css".
60+
html_static_path = ['_static']
61+
62+
# -- Automatically generate the Full help text in Shpinx build ---------------
63+
import pathlib
64+
import subprocess
65+
subprocess.run(
66+
["pydoctor", "--help"],
67+
stdout=(pathlib.Path(__file__).parent / "help.txt").open('w')
68+
)

doc/design-notes.txt renamed to docs/source/contrib.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Contribute
2+
==========
3+
4+
.. include:: ../../CONTRIBUTING.rst
5+
6+
Design Notes
7+
------------
8+
19
I guess I've always been interested in more-or-less static analysis of
210
Python code and have over time developed some fairly strong opinions
311
on the Right Way (tm) to do it.
@@ -20,3 +28,4 @@ Finally, pydoctor should never crash, no matter what code you feed it
2028
that universally applied, it seems). Missing information is OK,
2129
crashing out is not. This probably isn't as true as it should be at
2230
the moment.
31+

0 commit comments

Comments
 (0)