From: Vladimír Vondruš
Date: Sun, 24 Feb 2019 19:06:36 +0000 (+0100)
Subject: doxygen: option to show undocumented symbols.
X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=3044b35e325928d1c5c78ea1ec5ca912bfca56f0;p=blog.git
doxygen: option to show undocumented symbols.
Done simply as a preprocessing step by populating the
for each symbol that has neither nor
with an empty . That's all.
---
diff --git a/doc/doxygen.rst b/doc/doxygen.rst
index 6c4315fe..3c183ce0 100644
--- a/doc/doxygen.rst
+++ b/doc/doxygen.rst
@@ -183,7 +183,11 @@ If you see something unexpected or not see something expected, check the
- Files, directories and symbols that don't have any documentation are not
present in the output at all. This is done in order to encourage good
documentation practices --- having the output consist of an actual
- human-written documentation instead of just autogenerated lists.
+ human-written documentation instead of just autogenerated lists. If you
+ *really* want to have them included in the output, you can enable them
+ using a default-to-off :ini:`M_SHOW_UNDOCUMENTED` option, but there are
+ some tradeoffs. See `Showing undocumented symbols and files`_ for
+ more information.
- Table of contents is generated for compound references as well, containing
all sections of detailed description together with anchors to member
listings
@@ -399,6 +403,10 @@ Variable Description
search is offered. See `Search options`_
for more information. Has effect only if
:ini:`M_SEARCH_DISABLED` is not ``YES``.
+:ini:`M_SHOW_UNDOCUMENTED` Include undocumented symbols, files and
+ directories in the output. If not set,
+ ``NO`` is used. See `Showing undocumented symbols and files`_
+ for more information.
=================================== ===========================================
Note that namespace, directory and page lists are always fully expanded as
@@ -570,6 +578,26 @@ the search to a subdomain:
M_SEARCH_EXTERNAL_URL = "https://google.com/search?q=site:doc.magnum.graphics+{query}"
+`Showing undocumented symbols and files`_
+-----------------------------------------
+
+As noted in `Features`_, the main design decision of the m.css Doxygen theme is
+to reduce the amount of useless output. A plain list of undocumented APIs also
+counts as useless output, so by default everything that's not documented is not
+shown.
+
+In some cases, however, it might be desirable to show undocumented symbols as
+well --- for example when converting an existing project from vanilla Doxygen
+to m.css, not all APIs might be documented yet and thus the output would be
+incomplete. The :ini:`M_SHOW_UNDOCUMENTED` option unconditionally makes all
+undocumented symbols, files and directories "appear documented". Note, however,
+that Doxygen itself doesn't allow to link to undocumented symbols and so even
+though the undocumented symbols are present in the output, nothing is able to
+reference them, causing very questionable usability of such approach. A
+potential "fix" to this is enabling the :ini:`EXTRACT_ALL` option, but that
+exposes all symbols, including private and file-local ones --- which, most
+probably, is *not* what you want.
+
`Content`_
==========
diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py
index 6b917497..0585fa9e 100755
--- a/doxygen/dox2html5.py
+++ b/doxygen/dox2html5.py
@@ -1505,9 +1505,16 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
' class="{}"'.format(add_inline_css_class) if add_inline_css_class else '',
add_wbr(parse_inline_desc(state, i).strip()))
- # with custom CSS classes
+ # with custom CSS classes. This is (ab)used by the
+ # M_SHOW_UNDOCUMENTED option to make things appear to be documented
+ # in _document_all_stuff(). In that case the class attribute is not
+ # present.
elif i.tag == '{http://mcss.mosra.cz/doxygen/}span':
- out.parsed += '{}'.format(i.attrib['{http://mcss.mosra.cz/doxygen/}class'], parse_inline_desc(state, i).strip())
+ content = parse_inline_desc(state, i).strip()
+ if '{http://mcss.mosra.cz/doxygen/}class' in i.attrib:
+ out.parsed += '{}'.format(i.attrib['{http://mcss.mosra.cz/doxygen/}class'], content)
+ else:
+ out.parsed += '{}'.format(content)
# WHAT THE HELL WHY IS THIS NOT AN XML ENTITY
elif i.tag in ['mdash', 'ndash', 'laquo', 'raquo']:
@@ -2057,6 +2064,20 @@ def parse_define(state: State, element: ET.Element):
return define
return None
+# Used for the M_SHOW_UNDOCUMENTED option
+def _document_all_stuff(compounddef: ET.Element):
+ for i in compounddef.findall('.//briefdescription/..'):
+ brief = i.find('briefdescription')
+ if not brief and not i.find('detaileddescription'):
+ # Add an empty to the paragraph so it doesn't look empty.
+ # Can't use strong/emphasis, as those are collapsed if empty as
+ # well; on the other hand it's very unlikely that someone would
+ # want to use @m_span with empty contents.
+ dim = ET.Element('{http://mcss.mosra.cz/doxygen/}span')
+ para = ET.Element('para')
+ para.append(dim)
+ brief.append(para)
+
def extract_metadata(state: State, xml):
logging.debug("Extracting metadata from {}".format(os.path.basename(xml)))
@@ -2085,6 +2106,11 @@ def extract_metadata(state: State, xml):
logging.debug("No useful info in {}, skipping".format(os.path.basename(xml)))
return
+ # In order to show also undocumented members, go through all empty
+ # s and fill them with a generic text.
+ if state.doxyfile['M_SHOW_UNDOCUMENTED']:
+ _document_all_stuff(compounddef)
+
compound = StateCompound()
compound.id = compounddef.attrib['id']
compound.kind = compounddef.attrib['kind']
@@ -2392,6 +2418,11 @@ def parse_xml(state: State, xml: str):
logging.debug("{}: only private things, skipping".format(state.current))
return None
+ # In order to show also undocumented members, go through all empty
+ # s and fill them with a generic text.
+ if state.doxyfile['M_SHOW_UNDOCUMENTED']:
+ _document_all_stuff(compounddef)
+
# Ignoring compounds w/o any description, except for pages and groups,
# which are created explicitly
if not compounddef.find('briefdescription') and not compounddef.find('detaileddescription') and not compounddef.attrib['kind'] in ['page', 'group']:
@@ -3291,7 +3322,8 @@ copy a link to the result using âM produces a Markdown link.
Search for symbols, directories, files, pages or
+ modules. You can omit any prefix from the symbol or file path; adding a
+ : or / suffix lists all members of given symbol or
+ directory.
+
Use ↓
+ / ↑ to navigate through the list,
+ Enter to go.
+ Tab autocompletes common prefix, you can
+ copy a link to the result using â
+ L while â
+ M produces a Markdown link.
Search for symbols, directories, files, pages or
+ modules. You can omit any prefix from the symbol or file path; adding a
+ : or / suffix lists all members of given symbol or
+ directory.
+
Use ↓
+ / ↑ to navigate through the list,
+ Enter to go.
+ Tab autocompletes common prefix, you can
+ copy a link to the result using â
+ L while â
+ M produces a Markdown link.
+
+
Sorry, nothing was found.
+
+
+
+
+
+
+
+
+
+
diff --git a/doxygen/test/undocumented/classClass.html b/doxygen/test/undocumented/classClass.html
new file mode 100644
index 00000000..e2ce0751
--- /dev/null
+++ b/doxygen/test/undocumented/classClass.html
@@ -0,0 +1,92 @@
+
+
+
+
+ Class class | My Project
+
+
+
+
+
+
+
+
Search for symbols, directories, files, pages or
+ modules. You can omit any prefix from the symbol or file path; adding a
+ : or / suffix lists all members of given symbol or
+ directory.
+
Use ↓
+ / ↑ to navigate through the list,
+ Enter to go.
+ Tab autocompletes common prefix, you can
+ copy a link to the result using â
+ L while â
+ M produces a Markdown link.
Search for symbols, directories, files, pages or
+ modules. You can omit any prefix from the symbol or file path; adding a
+ : or / suffix lists all members of given symbol or
+ directory.
+
Use ↓
+ / ↑ to navigate through the list,
+ Enter to go.
+ Tab autocompletes common prefix, you can
+ copy a link to the result using â
+ L while â
+ M produces a Markdown link.
Search for symbols, directories, files, pages or
+ modules. You can omit any prefix from the symbol or file path; adding a
+ : or / suffix lists all members of given symbol or
+ directory.
+
Use ↓
+ / ↑ to navigate through the list,
+ Enter to go.
+ Tab autocompletes common prefix, you can
+ copy a link to the result using â
+ L while â
+ M produces a Markdown link.
Search for symbols, directories, files, pages or
+ modules. You can omit any prefix from the symbol or file path; adding a
+ : or / suffix lists all members of given symbol or
+ directory.
+
Use ↓
+ / ↑ to navigate through the list,
+ Enter to go.
+ Tab autocompletes common prefix, you can
+ copy a link to the result using â
+ L while â
+ M produces a Markdown link.
Search for symbols, directories, files, pages or
+ modules. You can omit any prefix from the symbol or file path; adding a
+ : or / suffix lists all members of given symbol or
+ directory.
+
Use ↓
+ / ↑ to navigate through the list,
+ Enter to go.
+ Tab autocompletes common prefix, you can
+ copy a link to the result using â
+ L while â
+ M produces a Markdown link.
Search for symbols, directories, files, pages or
+ modules. You can omit any prefix from the symbol or file path; adding a
+ : or / suffix lists all members of given symbol or
+ directory.
+
Use ↓
+ / ↑ to navigate through the list,
+ Enter to go.
+ Tab autocompletes common prefix, you can
+ copy a link to the result using â
+ L while â
+ M produces a Markdown link.