mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 22:45:18 +00:00
moved generating kea-messages.rst and api.rst from Makefile.am to sphinx's conf.py so they are generated on readthedocs.org as well
This commit is contained in:
@@ -52,8 +52,6 @@ rst_arm_sources+=arm/netconf.rst
|
|||||||
rst_arm_sources+=arm/quickstart.rst
|
rst_arm_sources+=arm/quickstart.rst
|
||||||
rst_arm_sources+=arm/shell.rst
|
rst_arm_sources+=arm/shell.rst
|
||||||
rst_arm_sources+=arm/stats.rst
|
rst_arm_sources+=arm/stats.rst
|
||||||
rst_arm_sources+=$(srcdir)/api.rst
|
|
||||||
rst_arm_sources+=$(srcdir)/kea-messages.rst
|
|
||||||
|
|
||||||
main_sources=$(rst_arm_sources) conf.py $(static_sources)
|
main_sources=$(rst_arm_sources) conf.py $(static_sources)
|
||||||
|
|
||||||
@@ -102,6 +100,9 @@ mes_files+=$(top_srcdir)/src/bin/dhcp6/dhcp6_messages.mes
|
|||||||
mes_files+=$(top_srcdir)/src/bin/lfc/lfc_messages.mes
|
mes_files+=$(top_srcdir)/src/bin/lfc/lfc_messages.mes
|
||||||
mes_files+=$(top_srcdir)/src/bin/netconf/netconf_messages.mes
|
mes_files+=$(top_srcdir)/src/bin/netconf/netconf_messages.mes
|
||||||
|
|
||||||
|
# this env variable is used in sphinx's conf.py where mes2doc.py is invoked
|
||||||
|
export KEA_MES_FILES=$(mes_files)
|
||||||
|
|
||||||
# list of api files that are used to generate api.rst
|
# list of api files that are used to generate api.rst
|
||||||
api_files=
|
api_files=
|
||||||
api_files+=$(srcdir)/api/build-report.json
|
api_files+=$(srcdir)/api/build-report.json
|
||||||
@@ -227,6 +228,9 @@ api_files+=$(srcdir)/api/subnet6-list.json
|
|||||||
api_files+=$(srcdir)/api/subnet6-update.json
|
api_files+=$(srcdir)/api/subnet6-update.json
|
||||||
api_files+=$(srcdir)/api/version-get.json
|
api_files+=$(srcdir)/api/version-get.json
|
||||||
|
|
||||||
|
# this env variable is used in sphinx's conf.py where api2doc.py is invoked
|
||||||
|
export KEA_API_FILES=$(api_files)
|
||||||
|
|
||||||
EXTRA_DIST += $(api_files)
|
EXTRA_DIST += $(api_files)
|
||||||
|
|
||||||
if HAVE_PDFLATEX
|
if HAVE_PDFLATEX
|
||||||
@@ -235,13 +239,6 @@ else
|
|||||||
all: html mans
|
all: html mans
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(srcdir)/kea-messages.rst: $(mes_files) mes2doc.py
|
|
||||||
$(PYTHON) $(srcdir)/mes2doc.py -o $@ $(mes_files)
|
|
||||||
|
|
||||||
|
|
||||||
$(srcdir)/api.rst: $(api_files) api2doc.py
|
|
||||||
$(PYTHON) $(srcdir)/api2doc.py -o $@ $(api_files)
|
|
||||||
|
|
||||||
|
|
||||||
PDFLATEX_AND_OPTS=$(PDFLATEX) -interaction nonstopmode
|
PDFLATEX_AND_OPTS=$(PDFLATEX) -interaction nonstopmode
|
||||||
|
|
||||||
@@ -289,7 +286,7 @@ uninstall-local:
|
|||||||
|
|
||||||
clean-local:
|
clean-local:
|
||||||
rm -rf $(sphinxbuilddir)
|
rm -rf $(sphinxbuilddir)
|
||||||
rm -f $(srcdir)/kea-messages.rst # $(srcdir)/api.rst
|
rm -f $(srcdir)/kea-messages.rst $(srcdir)/api.rst
|
||||||
|
|
||||||
.PHONY: all pdf html mans
|
.PHONY: all pdf html mans
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ def read_input_files(files):
|
|||||||
for f in files:
|
for f in files:
|
||||||
name = os.path.basename(f)[:-5]
|
name = os.path.basename(f)[:-5]
|
||||||
# Skip special names starting with _ (such as _template.json)
|
# Skip special names starting with _ (such as _template.json)
|
||||||
if name[0] == '_':
|
if name.startswith('_'):
|
||||||
print("Skipping %s (starts with underscore)" % f)
|
print("Skipping %s (starts with underscore)" % f)
|
||||||
continue
|
continue
|
||||||
with open(f) as fp:
|
with open(f) as fp:
|
||||||
@@ -170,18 +170,23 @@ API Reference
|
|||||||
return rst
|
return rst
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def generate(in_files, out_file):
|
||||||
args = parse_args()
|
apis = read_input_files(in_files)
|
||||||
|
|
||||||
apis = read_input_files(args.files)
|
|
||||||
|
|
||||||
rst = generate_rst(apis)
|
rst = generate_rst(apis)
|
||||||
|
|
||||||
if args.output:
|
if out_file:
|
||||||
with open(args.output, 'w') as f:
|
with open(out_file, 'w') as f:
|
||||||
f.write(rst)
|
f.write(rst)
|
||||||
|
print('Wrote generated RST content to: %s' % out_file)
|
||||||
else:
|
else:
|
||||||
print(rst)
|
print(rst)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = parse_args()
|
||||||
|
generate(args.files, args.output)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@@ -182,6 +182,25 @@ man_pages = [
|
|||||||
todo_include_todos = True
|
todo_include_todos = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Do generation of api.rst and kea-messages.rst here in conf.py instead of Makefile.am
|
||||||
|
# so they are available on ReadTheDocs as there makefiles are not used for building docs.
|
||||||
|
def run_generate_docs(_):
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
src_dir = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
print(src_dir)
|
||||||
|
sys.path.append(src_dir)
|
||||||
|
|
||||||
|
import api2doc
|
||||||
|
api2doc.generate(os.getenv('KEA_API_FILES').split(), os.path.join(src_dir, 'api.rst'))
|
||||||
|
|
||||||
|
import mes2doc
|
||||||
|
mes2doc.generate(os.getenv('KEA_MES_FILES').split(), os.path.join(src_dir, 'kea-messages.rst'))
|
||||||
|
|
||||||
|
|
||||||
# custom setup hook
|
# custom setup hook
|
||||||
def setup(app):
|
def setup(app):
|
||||||
app.add_stylesheet('kea.css')
|
app.add_stylesheet('kea.css')
|
||||||
|
|
||||||
|
app.connect('builder-inited', run_generate_docs)
|
||||||
|
@@ -37,6 +37,7 @@ def read_input_files(files):
|
|||||||
messages = {}
|
messages = {}
|
||||||
for f in files:
|
for f in files:
|
||||||
with open(f) as fp:
|
with open(f) as fp:
|
||||||
|
print("Processing %s" % f)
|
||||||
namespace = None
|
namespace = None
|
||||||
msg_descr = None
|
msg_descr = None
|
||||||
msg_id = None
|
msg_id = None
|
||||||
@@ -108,18 +109,23 @@ Kea, can be found in ISC's `Knowledgebase <https://kb.isc.org/docs/kea-administr
|
|||||||
|
|
||||||
return rst
|
return rst
|
||||||
|
|
||||||
def main():
|
def generate(in_files, out_file):
|
||||||
args = parse_args()
|
messages = read_input_files(in_files)
|
||||||
|
|
||||||
messages = read_input_files(args.files)
|
|
||||||
|
|
||||||
rst = generate_rst(messages)
|
rst = generate_rst(messages)
|
||||||
|
|
||||||
if args.output:
|
if out_file:
|
||||||
with open(args.output, 'w') as f:
|
with open(out_file, 'w') as f:
|
||||||
f.write(rst)
|
f.write(rst)
|
||||||
|
print('Wrote generated RST content to: %s' % out_file)
|
||||||
else:
|
else:
|
||||||
print(rst)
|
print(rst)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = parse_args()
|
||||||
|
generate(args.files, args.output)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Reference in New Issue
Block a user