mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-29 04:57:52 +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:
parent
8dd9c87d12
commit
357b9352f4
@ -52,8 +52,6 @@ rst_arm_sources+=arm/netconf.rst
|
||||
rst_arm_sources+=arm/quickstart.rst
|
||||
rst_arm_sources+=arm/shell.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)
|
||||
|
||||
@ -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/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
|
||||
api_files=
|
||||
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/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)
|
||||
|
||||
if HAVE_PDFLATEX
|
||||
@ -235,13 +239,6 @@ else
|
||||
all: html mans
|
||||
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
|
||||
|
||||
@ -289,7 +286,7 @@ uninstall-local:
|
||||
|
||||
clean-local:
|
||||
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
|
||||
|
||||
|
@ -30,7 +30,7 @@ def read_input_files(files):
|
||||
for f in files:
|
||||
name = os.path.basename(f)[:-5]
|
||||
# Skip special names starting with _ (such as _template.json)
|
||||
if name[0] == '_':
|
||||
if name.startswith('_'):
|
||||
print("Skipping %s (starts with underscore)" % f)
|
||||
continue
|
||||
with open(f) as fp:
|
||||
@ -170,18 +170,23 @@ API Reference
|
||||
return rst
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
apis = read_input_files(args.files)
|
||||
def generate(in_files, out_file):
|
||||
apis = read_input_files(in_files)
|
||||
|
||||
rst = generate_rst(apis)
|
||||
|
||||
if args.output:
|
||||
with open(args.output, 'w') as f:
|
||||
if out_file:
|
||||
with open(out_file, 'w') as f:
|
||||
f.write(rst)
|
||||
print('Wrote generated RST content to: %s' % out_file)
|
||||
else:
|
||||
print(rst)
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
generate(args.files, args.output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -182,6 +182,25 @@ man_pages = [
|
||||
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
|
||||
def setup(app):
|
||||
app.add_stylesheet('kea.css')
|
||||
|
||||
app.connect('builder-inited', run_generate_docs)
|
||||
|
@ -37,6 +37,7 @@ def read_input_files(files):
|
||||
messages = {}
|
||||
for f in files:
|
||||
with open(f) as fp:
|
||||
print("Processing %s" % f)
|
||||
namespace = None
|
||||
msg_descr = 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
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
messages = read_input_files(args.files)
|
||||
def generate(in_files, out_file):
|
||||
messages = read_input_files(in_files)
|
||||
|
||||
rst = generate_rst(messages)
|
||||
|
||||
if args.output:
|
||||
with open(args.output, 'w') as f:
|
||||
if out_file:
|
||||
with open(out_file, 'w') as f:
|
||||
f.write(rst)
|
||||
print('Wrote generated RST content to: %s' % out_file)
|
||||
else:
|
||||
print(rst)
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
generate(args.files, args.output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user