rst_arm_sources+=arm/quickstart.rst
rst_arm_sources+=arm/shell.rst
rst_arm_sources+=arm/stats.rst
-#rst_arm_sources+=$(srcdir)/api.rst TODO: disabled for now
+rst_arm_sources+=$(srcdir)/api.rst
rst_arm_sources+=$(srcdir)/kea-messages.rst
main_sources=$(rst_arm_sources) conf.py $(static_sources)
man_sources=$(rst_man_sources) conf.py
man8s=$(foreach rst,$(rst_man_sources), $(sphinxbuilddir)/$(basename $(rst)))
-EXTRA_DIST += $(main_sources) $(man_sources) mes2doc.py # api2doc.py
-
+EXTRA_DIST += $(main_sources) $(man_sources) mes2doc.py api2doc.py
# list of messages files that are used to generate kea-messages.rst and then kea-messages.pdf
mes_files=
api_files+=$(srcdir)/api/subnet6-update.json
api_files+=$(srcdir)/api/version-get.json
-#EXTRA_DIST += $(api_files)
-
+EXTRA_DIST += $(api_files)
if HAVE_PDFLATEX
all: html mans pdf
$(PYTHON) $(srcdir)/mes2doc.py -o $@ $(mes_files)
-#$(srcdir)/api.rst: $(api_files) api2doc.py
-# $(PYTHON) $(srcdir)/api2doc.py -o $@ $(api_files)
+$(srcdir)/api.rst: $(api_files) api2doc.py
+ $(PYTHON) $(srcdir)/api2doc.py -o $@ $(api_files)
PDFLATEX_AND_OPTS=$(PDFLATEX) -interaction nonstopmode
html: $(main_sources)
$(SPHINXBUILD) -M html $(srcdir) $(sphinxbuilddir) $(sphinxopts)
+singlehtml: $(main_sources)
+ $(SPHINXBUILD) -M singlehtml $(srcdir) $(sphinxbuilddir) $(sphinxopts)
+
$(man8s): mans
mans: $(man_sources)
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http:#mozilla.org/MPL/2.0/.
-# Produce API Manual
+# Produce API Reference
+# - reads *.json files (each file describes a single command)
+# - produces .rst file suitable for Sphinx as output
import os
import json
apis = {}
for f in files:
name = os.path.basename(f)[:-5]
+ # Skip special names starting with _ (such as _template.json)
+ if name[:1] == '_':
+ print("Skipping %s (starts with underscore)" % f)
+ continue
with open(f) as fp:
+ print("Processing %s" % f)
# use OrderedDict to preserve order of fields in cmd-syntax
try:
descr = json.load(fp, object_pairs_hook=collections.OrderedDict)
rst += '-' * len(name) + '\n\n'
# command overview
- rst += '%s\n\n' % func['brief']
+ for brief_line in func['brief']:
+ rst += '%s\n' % brief_line
+ rst += '\n'
# command can be issued to the following daemons
rst += 'Supported by: '
# command syntax
rst += 'Command syntax:\n\n'
- rst += '.. code-block:: json\n\n'
+ rst += '.. code-block:: \n\n'
if 'cmd-syntax' in func:
cmd_syntaxes = [func['cmd-syntax']]
if isinstance(cmd_syntaxes, dict):
rst += cmd_syntax['comment']
rst += '\n\n'
del cmd_syntax['comment']
- txt = json.dumps(cmd_syntax, indent=4, separators=(',', ': '))
- lines = [ ' %s' % l for l in txt.splitlines()]
- rst += '\n'.join(lines)
+
+ for line in cmd_syntax:
+ rst += ' %s\n' % line
else:
rst += ' {\n'
rst += ' "command": \"%s\"\n' % name
rst += '\n\n'
if 'cmd-comment' in func:
- rst += func['cmd-comment']
- rst += '\n\n'
+ for l in func['cmd-comment']:
+ rst += "%s\n" % l
+ rst += '\n'
# response syntax
rst += 'Response syntax:\n\n'
- rst += '.. code-block:: json\n\n'
+ rst += '.. code-block:: \n\n'
if 'resp-syntax' in func:
resp_syntaxes = [func['resp-syntax']]
if isinstance(resp_syntaxes, dict):
resp_syntaxes = [resp_syntax]
for resp_syntax in resp_syntaxes:
- txt = json.dumps(resp_syntax, indent=4, separators=(',', ': '))
- lines = [ ' %s' % l for l in txt.splitlines()]
- rst += '\n'.join(lines)
+
+ for line in resp_syntax:
+ rst += ' %s\n' % line
+
+ #txt = json.dumps(resp_syntax, indent=4, separators=(',', ': '))
+ #lines = [ ' %s' % l for l in txt.splitlines()]
+ #rst += '\n'.join(lines)
else:
rst += ' {\n'
rst += ' "result": "<integer>",\n'
rst += '\n\n'
if 'resp-comment' in func:
- rst += func['resp-comment']
+ for resp_comment_line in func['resp-comment']:
+ rst += "%s\n" % resp_comment_line
rst += '\n\n'
else:
rst += 'Result is an integer representation of the status. Currently supported statuses are:\n\n'