[gi-docgen: 2/5] commandline search: Add constant support




commit b942c7415585aca6ab264c9993a711fcd8cc5b5d
Author: FeRD (Frank Dana) <ferdnyc gmail com>
Date:   Mon Mar 21 08:22:24 2022 -0400

    commandline search: Add constant support

 gidocgen/gdsearch.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/gidocgen/gdsearch.py b/gidocgen/gdsearch.py
index f5483d3..ba10734 100644
--- a/gidocgen/gdsearch.py
+++ b/gidocgen/gdsearch.py
@@ -89,6 +89,23 @@ def _gen_class_method_result(symbol, namespace):
     return None
 
 
+def _gen_constant_result(symbol, namespace):
+    const = namespace.find_real_type(symbol["name"])
+
+    if const.doc is not None:
+        summary = utils.preprocess_docs(const.doc.content, namespace, summary=True, plain=True)
+    else:
+        summary = "Missing documentation"
+
+    return {
+        "type": "constant",
+        "name": const.name,
+        "ctype": const.ctype,
+        "summary": summary.split("\n"),
+        "link": f"const.{const.name}.html",
+    }
+
+
 def _gen_ctor_result(symbol, namespace):
     t = namespace.find_real_type(symbol["type_name"])
 
@@ -357,6 +374,7 @@ def query(repository, terms, index_file):
         "callback": _gen_callback_result,
         "class": _gen_class_result,
         "class_method": _gen_class_method_result,
+        "constant": _gen_constant_result,
         "ctor": _gen_ctor_result,
         "domain": _gen_domain_result,
         "enum": _gen_enum_result,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]