Skip to content

Commit 68f2cf3

Browse files
committed
(backport) Make docs build independent of app
1 parent 0094acd commit 68f2cf3

File tree

11 files changed

+306
-277
lines changed

11 files changed

+306
-277
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ Package maintainers and users who have to manually update their installation
99
may want to subscribe to `GitHub's tag feed
1010
<https://github.com/pimutils/vdirsyncer/tags.atom>`_.
1111

12-
Version 0.16.5
12+
Version 0.16.6
1313
==============
1414

15-
*released on 13 June 2018*
15+
- **Packagers:** Documentation building no longer needs a working installation
16+
of vdirsyncer.
17+
18+
Version 0.16.5
19+
==============
1620

1721
- **Packagers:** click-log 0.3 is required.
1822
- All output will now happen on stderr (because of the upgrade of ``click-log``).
1923

20-
2124
Version 0.16.4
2225
==============
2326

docs-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
sphinx != 1.4.7
22
sphinx_rtd_theme
3+
setuptools_scm

docs/conf.py

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from sphinx.ext import autodoc
88

9-
import vdirsyncer
9+
import setuptools_scm
1010

1111
extensions = ['sphinx.ext.autodoc']
1212

@@ -19,7 +19,7 @@
1919
copyright = (u'2014-{}, Markus Unterwaditzer & contributors'
2020
.format(datetime.date.today().strftime('%Y')))
2121

22-
release = vdirsyncer.__version__
22+
release = setuptools_scm.get_version(root='..', relative_to=__file__)
2323
version = '.'.join(release.split('.')[:2]) # The short X.Y version.
2424

2525
rst_epilog = '.. |vdirsyncer_version| replace:: %s' % release
@@ -75,9 +75,10 @@ def github_issue_role(name, rawtext, text, lineno, inliner,
7575
prb = inliner.problematic(rawtext, rawtext, msg)
7676
return [prb], [msg]
7777

78-
import vdirsyncer
7978
from docutils import nodes
80-
link = '{}/{}/{}'.format(vdirsyncer.PROJECT_HOME,
79+
80+
PROJECT_HOME = 'https://github.com/pimutils/vdirsyncer'
81+
link = '{}/{}/{}'.format(PROJECT_HOME,
8182
'issues' if name == 'gh' else 'pull',
8283
issue_num)
8384
linktext = ('issue #{}' if name == 'gh'
@@ -87,64 +88,9 @@ def github_issue_role(name, rawtext, text, lineno, inliner,
8788
return [node], []
8889

8990

90-
def format_storage_config(cls, header=True):
91-
if header is True:
92-
yield '[storage example_for_{}]'.format(cls.storage_name)
93-
yield 'type = "{}"'.format(cls.storage_name)
94-
95-
from vdirsyncer.storage.base import Storage
96-
from vdirsyncer.utils import get_storage_init_specs
97-
handled = set()
98-
for spec in get_storage_init_specs(cls, stop_at=Storage):
99-
defaults = spec.defaults or ()
100-
defaults = dict(zip(spec.args[-len(defaults):], defaults))
101-
for key in spec.args[1:]:
102-
if key in handled:
103-
continue
104-
handled.add(key)
105-
106-
comment = '' if key not in defaults else '#'
107-
value = defaults.get(key, '...')
108-
yield '{}{} = {}'.format(comment, key, json.dumps(value))
109-
110-
111-
class StorageDocumenter(autodoc.ClassDocumenter):
112-
'''Custom formatter for auto-documenting storage classes. It assumes that
113-
the first line of the class' docstring is its own paragraph.
114-
115-
After that first paragraph, an example configuration will be inserted and
116-
Sphinx' __init__ signature removed.'''
117-
118-
objtype = 'storage'
119-
domain = None
120-
directivetype = 'storage'
121-
option_spec = {}
122-
123-
@classmethod
124-
def can_document_member(cls, member, membername, isattr, parent):
125-
from vdirsyncer.storage.base import Storage
126-
return isinstance(member, Storage)
127-
128-
def format_signature(self):
129-
return ''
130-
131-
def add_directive_header(self, sig):
132-
directive = getattr(self, 'directivetype', self.objtype)
133-
name = self.object.storage_name
134-
self.add_line(u'.. %s:: %s%s' % (directive, name, sig),
135-
'<autodoc>')
136-
137-
def get_doc(self, encoding=None, ignore=1):
138-
rv = autodoc.ClassDocumenter.get_doc(self, encoding, ignore)
139-
config = [u' ' + x for x in format_storage_config(self.object)]
140-
rv[0] = rv[0][:1] + [u'::', u''] + config + [u''] + rv[0][1:]
141-
return rv
142-
143-
14491
def setup(app):
14592
from sphinx.domains.python import PyObject
14693
app.add_object_type('storage', 'storage', 'pair: %s; storage',
14794
doc_field_types=PyObject.doc_field_types)
14895
app.add_role('gh', github_issue_role)
14996
app.add_role('ghpr', github_issue_role)
150-
app.add_autodocumenter(StorageDocumenter)

0 commit comments

Comments
 (0)