Skip to content

Commit

Permalink
docs: add source to watch dirs when using API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jhermann committed Jul 7, 2020
1 parent df3b187 commit dbeabe8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/rituals/acts/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,18 @@ def sphinx(ctx, browse=False, clean=False, watchdog=False, kill=False, status=Fa
out.write(' {}\n'.format(license_text))

# Build API docs
if cfg.project.get('packages') and str(ctx.rituals.docs.apidoc).lower()[:1] in 't1y':
cmd = ['sphinx-apidoc', '-o', 'api', '-f', '-M']
def append_pkg_dirs(cmd, option=None):
"""Helper to add source dirs."""
for package in cfg.project.packages:
if '.' not in package:
if option:
cmd.append(option)
cmd.append(cfg.srcjoin(package))

apidocs = cfg.project.get('packages') and str(ctx.rituals.docs.apidoc).lower()[:1] in 't1y'
if apidocs:
cmd = ['sphinx-apidoc', '-o', 'api', '-f', '-M']
append_pkg_dirs(cmd)
with pushd(ctx.rituals.docs.sources):
ctx.run(' '.join(cmd))

Expand All @@ -171,6 +178,8 @@ def sphinx(ctx, browse=False, clean=False, watchdog=False, kill=False, status=Fa
if watchdog:
watchdogctl(ctx, kill=True)
cmd[0:1] = ['nohup', 'sphinx-autobuild']
if apidocs:
append_pkg_dirs(cmd, option='-z')
cmd.extend([
'-H', ctx.rituals.docs.watchdog.host,
'-p', '{}'.format(ctx.rituals.docs.watchdog.port),
Expand Down

0 comments on commit dbeabe8

Please sign in to comment.