From 6084245033f4910e7bc8437cac0d76c2087c88f9 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Tue, 3 Jun 2025 16:23:16 +0200 Subject: [PATCH] Add support to build api-ref as plain text To be able to do that stanzas: "rest_method", "rest_expand_all" and "http_code" are required for the "text" sphinx node visitor function. Change-Id: Ib5e298dc0355886d1c373df1b82454390db8487a --- os_api_ref/__init__.py | 18 +++++++++++++++--- os_api_ref/http_codes.py | 4 ++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/os_api_ref/__init__.py b/os_api_ref/__init__.py index 957025f..3e5cc93 100644 --- a/os_api_ref/__init__.py +++ b/os_api_ref/__init__.py @@ -26,6 +26,7 @@ import yaml from os_api_ref.http_codes import http_code from os_api_ref.http_codes import http_code_html +from os_api_ref.http_codes import http_code_text from os_api_ref.http_codes import HTTPResponseCodeDirective __version__ = pbr.version.VersionInfo( @@ -555,6 +556,14 @@ def rest_expand_all_html(self, node): raise nodes.SkipNode +def rest_method_text(self, node): + raise nodes.SkipNode + + +def rest_expand_all_text(self, node): + raise nodes.SkipNode + + def create_mv_selector(node): mv_list = '' @@ -672,9 +681,12 @@ def setup(app): # TODO(sdague): if someone wants to support latex/pdf, or man page # generation using these stanzas, here is where you'd need to # specify content specific renderers. - app.add_node(rest_method, html=(rest_method_html, None)) - app.add_node(rest_expand_all, html=(rest_expand_all_html, None)) - app.add_node(http_code, html=(http_code_html, None)) + app.add_node(rest_method, html=(rest_method_html, None), + text=(rest_method_text, None)) + app.add_node(rest_expand_all, html=(rest_expand_all_html, None), + text=(rest_expand_all_text, None)) + app.add_node(http_code, html=(http_code_html, None), + text=(http_code_text, None)) # This specifies all our directives that we're adding app.add_directive('rest_parameters', RestParametersDirective) diff --git a/os_api_ref/http_codes.py b/os_api_ref/http_codes.py index 046e43c..d7339ef 100644 --- a/os_api_ref/http_codes.py +++ b/os_api_ref/http_codes.py @@ -221,6 +221,10 @@ def http_code_html(self, node): raise nodes.SkipNode +def http_code_text(self, node): + raise nodes.SkipNode + + class http_code(nodes.Part, nodes.Element): """Node for http_code stanza