mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Move docs code out of vdirsyncer
This commit is contained in:
parent
e54f5b89a3
commit
94fe934ec2
2 changed files with 21 additions and 22 deletions
22
docs/conf.py
22
docs/conf.py
|
|
@ -84,6 +84,27 @@ def github_issue_role(name, rawtext, text, lineno, inliner,
|
||||||
return [node], []
|
return [node], []
|
||||||
|
|
||||||
|
|
||||||
|
def format_storage_config(cls, header=True):
|
||||||
|
if header is True:
|
||||||
|
yield '[storage example_for_{}]'.format(cls.storage_name)
|
||||||
|
yield 'type = {}'.format(cls.storage_name)
|
||||||
|
|
||||||
|
from ..storage.base import Storage
|
||||||
|
from ..utils import get_storage_init_specs
|
||||||
|
handled = set()
|
||||||
|
for spec in get_storage_init_specs(cls, stop_at=Storage):
|
||||||
|
defaults = spec.defaults or ()
|
||||||
|
defaults = dict(zip(spec.args[-len(defaults):], defaults))
|
||||||
|
for key in spec.args[1:]:
|
||||||
|
if key in handled:
|
||||||
|
continue
|
||||||
|
handled.add(key)
|
||||||
|
|
||||||
|
comment = '' if key not in defaults else '#'
|
||||||
|
value = defaults.get(key, '...')
|
||||||
|
yield '{}{} = {}'.format(comment, key, json.dumps(value))
|
||||||
|
|
||||||
|
|
||||||
class StorageDocumenter(autodoc.ClassDocumenter):
|
class StorageDocumenter(autodoc.ClassDocumenter):
|
||||||
'''Custom formatter for auto-documenting storage classes. It assumes that
|
'''Custom formatter for auto-documenting storage classes. It assumes that
|
||||||
the first line of the class' docstring is its own paragraph.
|
the first line of the class' docstring is its own paragraph.
|
||||||
|
|
@ -111,7 +132,6 @@ class StorageDocumenter(autodoc.ClassDocumenter):
|
||||||
'<autodoc>')
|
'<autodoc>')
|
||||||
|
|
||||||
def get_doc(self, encoding=None, ignore=1):
|
def get_doc(self, encoding=None, ignore=1):
|
||||||
from vdirsyncer.cli.utils import format_storage_config
|
|
||||||
rv = autodoc.ClassDocumenter.get_doc(self, encoding, ignore)
|
rv = autodoc.ClassDocumenter.get_doc(self, encoding, ignore)
|
||||||
config = [u' ' + x for x in format_storage_config(self.object)]
|
config = [u' ' + x for x in format_storage_config(self.object)]
|
||||||
rv[0] = rv[0][:1] + [u'::', u''] + config + [u''] + rv[0][1:]
|
rv[0] = rv[0][:1] + [u'::', u''] + config + [u''] + rv[0][1:]
|
||||||
|
|
|
||||||
|
|
@ -358,27 +358,6 @@ class WorkerQueue(object):
|
||||||
return self._queue.put(f)
|
return self._queue.put(f)
|
||||||
|
|
||||||
|
|
||||||
def format_storage_config(cls, header=True):
|
|
||||||
if header is True:
|
|
||||||
yield '[storage example_for_{}]'.format(cls.storage_name)
|
|
||||||
yield 'type = {}'.format(cls.storage_name)
|
|
||||||
|
|
||||||
from ..storage.base import Storage
|
|
||||||
from ..utils import get_storage_init_specs
|
|
||||||
handled = set()
|
|
||||||
for spec in get_storage_init_specs(cls, stop_at=Storage):
|
|
||||||
defaults = spec.defaults or ()
|
|
||||||
defaults = dict(zip(spec.args[-len(defaults):], defaults))
|
|
||||||
for key in spec.args[1:]:
|
|
||||||
if key in handled:
|
|
||||||
continue
|
|
||||||
handled.add(key)
|
|
||||||
|
|
||||||
comment = '' if key not in defaults else '#'
|
|
||||||
value = defaults.get(key, '...')
|
|
||||||
yield '{}{} = {}'.format(comment, key, json.dumps(value))
|
|
||||||
|
|
||||||
|
|
||||||
def assert_permissions(path, wanted):
|
def assert_permissions(path, wanted):
|
||||||
permissions = os.stat(path).st_mode & 0o777
|
permissions = os.stat(path).st_mode & 0o777
|
||||||
if permissions > wanted:
|
if permissions > wanted:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue