From 8cad88d72c343fd1091b6dab85ecb226c062a9da Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Mon, 6 Nov 2023 23:13:09 +0100 Subject: [PATCH 1/2] geanygendoc: Do not crash if documenting an unknown tag type --- geanygendoc/src/ggd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geanygendoc/src/ggd.c b/geanygendoc/src/ggd.c index b60d9d79b..bc55a300f 100644 --- a/geanygendoc/src/ggd.c +++ b/geanygendoc/src/ggd.c @@ -208,7 +208,7 @@ get_env_for_tag (GgdFileType *ft, CtplValue *v; GList *tmp = children; - if (el->type & setting->matches) { + if (type_name && el->type & setting->matches) { v = g_hash_table_lookup (vars, type_name); if (! v) { v = ctpl_value_new_array (CTPL_VTYPE_STRING, 0, NULL); From 3af0bf5117a1143b20286f5ee9fb0a2c35916d6b Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Mon, 6 Nov 2023 23:14:02 +0100 Subject: [PATCH 2/2] geanygendoc: Add support for local variables Since Geany 2.0 a lot of those are reported for several languages, including C. Those should usually not be documented, but their parent should be instead, otherwise they "get in the way" of triggering documentation of their parent. Add support for the "local" match rule for local variables, and update the default rules to use the FORWARD policy for them. It's not actually the parent documenting the child, but the effect is the same as the user probably wanted to document the parent rather than the local. --- geanygendoc/data/filetypes/c.conf | 5 +++++ geanygendoc/docs/manual.rst | 2 ++ geanygendoc/src/ggd-tag-utils.c | 1 + 3 files changed, 8 insertions(+) diff --git a/geanygendoc/data/filetypes/c.conf b/geanygendoc/data/filetypes/c.conf index 506d73da7..1159b15ae 100644 --- a/geanygendoc/data/filetypes/c.conf +++ b/geanygendoc/data/filetypes/c.conf @@ -41,6 +41,8 @@ doctypes = { struct.prototype.policy = FORWARD; member.policy = FORWARD; enumval.policy = FORWARD; + # usually, locals are just not documented and get in the way + local.policy = FORWARD; function = { template = "/**\n * {symbol}:\n{for arg in argument_list} * @{arg}: {cursor}\n{end} * \n * {cursor}\n{if returns} * \n * Returns: \n{end}{if write_since}{if returns} * \n{end} * Since: \n{end} */\n"; @@ -73,6 +75,9 @@ doctypes = { } doxygen = { + # usually, locals are just not documented and get in the way + local.policy = FORWARD; + function.template = "/**\n * {doxygen_prefix}brief {cursor}\n{for a in argument_list} * {doxygen_prefix}param {a} \n{end}{if returns} * {doxygen_prefix}returns \n{end}{if write_since} * {doxygen_prefix}since \n{end} * \n * \n */\n"; macro.template = "/**\n * {doxygen_prefix}brief {cursor}\n{for a in argument_list} * {doxygen_prefix}param {a} \n{end}{if returns} * {doxygen_prefix}returns \n{end}{if write_since} * {doxygen_prefix}since \n{end} * \n * \n */\n"; struct.member = { diff --git a/geanygendoc/docs/manual.rst b/geanygendoc/docs/manual.rst index 8c492d842..10f4f45e5 100644 --- a/geanygendoc/docs/manual.rst +++ b/geanygendoc/docs/manual.rst @@ -348,6 +348,8 @@ Known types A function. ``interface`` An interface. +``local`` + A local variable. ``member`` A member (of a structure for example). ``method`` diff --git a/geanygendoc/src/ggd-tag-utils.c b/geanygendoc/src/ggd-tag-utils.c index a5a3b0425..1d1fff800 100644 --- a/geanygendoc/src/ggd-tag-utils.c +++ b/geanygendoc/src/ggd-tag-utils.c @@ -255,6 +255,7 @@ static const struct { { tm_tag_field_t, "field" }, { tm_tag_function_t, "function" }, { tm_tag_interface_t, "interface" }, + { tm_tag_local_var_t, "local" }, { tm_tag_member_t, "member" }, { tm_tag_method_t, "method" }, { tm_tag_namespace_t, "namespace" },