| ############################################################################## |
| # If not stated otherwise in this file or this component's LICENSE file the |
| # following copyright and licenses apply: |
| # |
| # Copyright 2022 Liberty Global Service BV |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| ############################################################################## |
| |
| From 6a4a6e3af07caf98a6d290a295b39d279129d7f3 Mon Sep 17 00:00:00 2001 |
| From: Vladimir Veretennikov <vladimir.veretennikov@zodiacsystems.com> |
| Date: Thu, 28 Jan 2021 15:09:18 +0700 |
| Subject: [PATCH 1/1] Simplified docs generation |
| |
| --- |
| Tools/JsonGenerator/JsonGenerator.py | 200 +++++++++++++++------------ |
| 1 file changed, 111 insertions(+), 89 deletions(-) |
| |
| diff --git a/Tools/JsonGenerator/JsonGenerator.py b/Tools/JsonGenerator/JsonGenerator.py |
| index b620aac1..15e0322a 100755 |
| --- a/Tools/JsonGenerator/JsonGenerator.py |
| +++ b/Tools/JsonGenerator/JsonGenerator.py |
| @@ -37,6 +37,8 @@ VERSION = "1.7.1" |
| DEFAULT_DEFINITIONS_FILE = "../ProxyStubGenerator/default.h" |
| FRAMEWORK_NAMESPACE = "WPEFramework" |
| INTERFACE_NAMESPACE = FRAMEWORK_NAMESPACE + "::Exchange" |
| +SIMPLE = False |
| +CONFLUENCE = False |
| VERBOSE = False |
| NO_DUP_WARNINGS = False |
| |
| @@ -2097,7 +2099,7 @@ def CreateDocument(schema, path): |
| def MdHeader(string, level=1, id="head", include=None): |
| if level < 3: |
| emit.Line("<a name=\"%s\"></a>" % (id + "." + string.replace(" ", "_"))) |
| - if id != "head": |
| + if id != "head" and not CONFLUENCE: |
| string += " <sup>%s</sup>" % id |
| emit.Line("%s %s" % ("#" * level, "*%s*" % string if id != "head" else string)) |
| MdBr() |
| @@ -2414,26 +2416,32 @@ def CreateDocument(schema, path): |
| document_type = "interface" |
| |
| # Emit title bar |
| - if "title" in info: |
| - MdHeader(info["title"]) |
| + if CONFLUENCE: |
| + MdHeader("Version") |
| + else: |
| + if "title" in info: |
| + MdHeader(info["title"]) |
| MdParagraph(bold("Version: " + version)) |
| - MdParagraph(bold("Status: " + rating * ":black_circle:" + (3 - rating) * ":white_circle:")) |
| - MdParagraph("%s %s for Thunder framework." % (plugin_class, document_type)) |
| - |
| - # Emit TOC. |
| - MdHeader("Table of Contents", 3) |
| - MdBody("- " + link("head.Introduction")) |
| - if "description" in info: |
| - MdBody("- " + link("head.Description")) |
| - if document_type == "plugin": |
| - MdBody("- " + link("head.Configuration")) |
| - if method_count: |
| - MdBody("- " + link("head.Methods")) |
| - if property_count: |
| - MdBody("- " + link("head.Properties")) |
| - if event_count: |
| - MdBody("- " + link("head.Notifications")) |
| - MdBr() |
| + if not SIMPLE: |
| + MdParagraph(bold("Status: " + rating * ":black_circle:" + (3 - rating) * ":white_circle:")) |
| + MdParagraph("%s %s for Thunder framework." % (plugin_class, document_type)) |
| + |
| + if not CONFLUENCE: |
| + # Emit TOC. |
| + MdHeader("Table of Contents", 3) |
| + if not SIMPLE: |
| + MdBody("- " + link("head.Introduction")) |
| + if "description" in info: |
| + MdBody("- " + link("head.Description")) |
| + if document_type == "plugin": |
| + MdBody("- " + link("head.Configuration")) |
| + if method_count: |
| + MdBody("- " + link("head.Methods")) |
| + if property_count: |
| + MdBody("- " + link("head.Properties")) |
| + if event_count: |
| + MdBody("- " + link("head.Notifications")) |
| + MdBr() |
| |
| def mergedict(d1, d2, prop): |
| tmp = dict() |
| @@ -2443,68 +2451,69 @@ def CreateDocument(schema, path): |
| tmp.update(d2[prop]) |
| return tmp |
| |
| - MdHeader("Introduction") |
| - MdHeader("Scope", 2) |
| - if "scope" in info: |
| - MdParagraph(info["scope"]) |
| - elif "title" in info: |
| - extra = "" |
| - if document_type == 'plugin': |
| - extra = "configuration" |
| - if method_count and property_count and event_count: |
| + if not SIMPLE: |
| + MdHeader("Introduction") |
| + MdHeader("Scope", 2) |
| + if "scope" in info: |
| + MdParagraph(info["scope"]) |
| + elif "title" in info: |
| + extra = "" |
| + if document_type == 'plugin': |
| + extra = "configuration" |
| + if method_count and property_count and event_count: |
| + if extra: |
| + extra += ", " |
| + extra += "methods and properties provided, as well as notifications sent" |
| + elif method_count and property_count: |
| + if extra: |
| + extra += ", " |
| + extra += "methods and properties provided" |
| + elif method_count and event_count: |
| + if extra: |
| + extra += ", " |
| + extra += "methods provided and notifications sent" |
| + elif property_count and event_count: |
| + if extra: |
| + extra += ", " |
| + extra += "properties provided and notifications sent" |
| + elif method_count: |
| + if extra: |
| + extra += " and " |
| + extra += "methods provided" |
| + elif property_count: |
| + if extra: |
| + extra += " and " |
| + extra += "properties provided" |
| + elif event_count: |
| + if extra: |
| + extra += " and " |
| + extra += "notifications sent" |
| if extra: |
| - extra += ", " |
| - extra += "methods and properties provided, as well as notifications sent" |
| - elif method_count and property_count: |
| - if extra: |
| - extra += ", " |
| - extra += "methods and properties provided" |
| - elif method_count and event_count: |
| - if extra: |
| - extra += ", " |
| - extra += "methods provided and notifications sent" |
| - elif property_count and event_count: |
| - if extra: |
| - extra += ", " |
| - extra += "properties provided and notifications sent" |
| - elif method_count: |
| - if extra: |
| - extra += " and " |
| - extra += "methods provided" |
| - elif property_count: |
| - if extra: |
| - extra += " and " |
| - extra += "properties provided" |
| - elif event_count: |
| - if extra: |
| - extra += " and " |
| - extra += "notifications sent" |
| - if extra: |
| - extra = " It includes detailed specification about its " + extra + "." |
| - MdParagraph("This document describes purpose and functionality of the %s %s.%s" % (plugin_class, document_type, extra)) |
| - |
| - MdHeader("Case Sensitivity", 2) |
| - MdParagraph(( |
| - "All identifiers of the interfaces described in this document are case-sensitive. " |
| - "Thus, unless stated otherwise, all keywords, entities, properties, relations and actions should be treated as such." |
| - )) |
| - |
| - if "acronyms" in info or "acronyms" in commons or "terms" in info or "terms" in commons: |
| - MdHeader("Acronyms, Abbreviations and Terms", 2) |
| - if "acronyms" in info or "acronyms" in commons: |
| - MdParagraph("The table below provides and overview of acronyms used in this document and their definitions.") |
| - PlainTable(mergedict(commons, info, "acronyms"), ["Acronym", "Description"], "acronym") |
| - if "terms" in info or "terms" in commons: |
| - MdParagraph("The table below provides and overview of terms and abbreviations used in this document and their definitions.") |
| - PlainTable(mergedict(commons, info, "terms"), ["Term", "Description"], "term") |
| - |
| - if "standards" in info: |
| - MdHeader("Standards", 2) |
| - MdParagraph(info["standards"]) |
| - |
| - if "references" in commons or "references" in info: |
| - MdHeader("References", 2) |
| - PlainTable(mergedict(commons, info, "references"), ["Ref ID", "Description"]) |
| + extra = " It includes detailed specification about its " + extra + "." |
| + MdParagraph("This document describes purpose and functionality of the %s %s.%s" % (plugin_class, document_type, extra)) |
| + |
| + MdHeader("Case Sensitivity", 2) |
| + MdParagraph(( |
| + "All identifiers of the interfaces described in this document are case-sensitive. " |
| + "Thus, unless stated otherwise, all keywords, entities, properties, relations and actions should be treated as such." |
| + )) |
| + |
| + if "acronyms" in info or "acronyms" in commons or "terms" in info or "terms" in commons: |
| + MdHeader("Acronyms, Abbreviations and Terms", 2) |
| + if "acronyms" in info or "acronyms" in commons: |
| + MdParagraph("The table below provides and overview of acronyms used in this document and their definitions.") |
| + PlainTable(mergedict(commons, info, "acronyms"), ["Acronym", "Description"], "acronym") |
| + if "terms" in info or "terms" in commons: |
| + MdParagraph("The table below provides and overview of terms and abbreviations used in this document and their definitions.") |
| + PlainTable(mergedict(commons, info, "terms"), ["Term", "Description"], "term") |
| + |
| + if "standards" in info: |
| + MdHeader("Standards", 2) |
| + MdParagraph(info["standards"]) |
| + |
| + if "references" in commons or "references" in info: |
| + MdHeader("References", 2) |
| + PlainTable(mergedict(commons, info, "references"), ["Ref ID", "Description"]) |
| |
| if "description" in info: |
| MdHeader("Description") |
| @@ -2564,7 +2573,8 @@ def CreateDocument(schema, path): |
| if contents and method not in skip_list: |
| ns = interface["info"]["namespace"] if "namespace" in interface["info"] else "" |
| if not head: |
| - MdParagraph("%s interface %s:" % (((ns + " ") if ns else "") + interface["info"]["class"], section)) |
| + if not SIMPLE: |
| + MdParagraph("%s interface %s:" % (((ns + " ") if ns else "") + interface["info"]["class"], section)) |
| MdTableHeader([header.capitalize(), "Description"]) |
| head = True |
| access = "" |
| @@ -2594,10 +2604,10 @@ def CreateDocument(schema, path): |
| if description: |
| MdParagraph(description) |
| |
| - MdParagraph("The following %s are provided by the %s %s:" % (section, plugin_class, document_type)) |
| - |
| - for interface in interfaces: |
| - InterfaceDump(interface, section, header) |
| + if not CONFLUENCE: |
| + MdParagraph("The following %s are provided by the %s %s:" % (section, plugin_class, document_type)) |
| + for interface in interfaces: |
| + InterfaceDump(interface, section, header) |
| |
| MdBr() |
| if description2: |
| @@ -2620,13 +2630,21 @@ def CreateDocument(schema, path): |
| SectionDump("Properties", "properties", "property", prop=True) |
| |
| if event_count: |
| - SectionDump("Notifications", |
| + if SIMPLE: |
| + SectionDump("Notifications", |
| "events", |
| "event", |
| ("Notifications are autonomous events, triggered by the internals of the implementation, " |
| - "and broadcasted via JSON-RPC to all registered observers. " |
| - "Refer to [[Thunder](#ref.Thunder)] for information on how to register for a notification."), |
| + "and broadcasted via JSON-RPC to all registered observers. "), |
| event=True) |
| + else: |
| + SectionDump("Notifications", |
| + "events", |
| + "event", |
| + ("Notifications are autonomous events, triggered by the internals of the implementation, " |
| + "and broadcasted via JSON-RPC to all registered observers. " |
| + "Refer to [[Thunder](#ref.Thunder)] for information on how to register for a notification."), |
| + event=True) |
| |
| trace.Success("Document created: %s" % output_path) |
| |
| @@ -2732,6 +2750,8 @@ if __name__ == "__main__": |
| argparser.add_argument('path', nargs="*", help="JSON file(s), wildcards are allowed") |
| argparser.add_argument("--version", dest="version", action="store_true", default=False, help="display version") |
| argparser.add_argument("--verbose", dest="verbose", action="store_true", default=False, help="be verbose") |
| + argparser.add_argument("--simple", dest="simple", action="store_true", default=False, help="generate simple generic doc") |
| + argparser.add_argument("--confluence", dest="confluence", action="store_true", default=False, help="generate doc to paste to confluence (implies simple)") |
| argparser.add_argument("-d", |
| "--docs", |
| dest="docs", |
| @@ -2855,6 +2875,8 @@ if __name__ == "__main__": |
| |
| args = argparser.parse_args(sys.argv[1:]) |
| |
| + SIMPLE = args.simple or args.confluence |
| + CONFLUENCE = args.confluence |
| VERBOSE = args.verbose |
| VERIFY = not args.no_style_warnings |
| INDENT_SIZE = args.indent_size |
| -- |
| 2.30.0 |
| |