diff options
| author | Jordan Wiens <github@psifertex.com> | 2025-10-23 16:15:27 -0400 |
|---|---|---|
| committer | Jordan <github@psifertex.com> | 2025-11-06 10:32:46 -0500 |
| commit | 5a6b4fcc110effbb3e87c85d3d22876697b5b9e9 (patch) | |
| tree | 50c2bd735d17782c572201c4314c4e9bdc871f5a /api-docs/cppdocs/build_min_docs.py | |
| parent | 3ac256071afab7ac29dc8236297a99b5c10ab0b9 (diff) | |
update cppdocs to support newer doxygen versions (resolves #7439)
Diffstat (limited to 'api-docs/cppdocs/build_min_docs.py')
| -rw-r--r-- | api-docs/cppdocs/build_min_docs.py | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/api-docs/cppdocs/build_min_docs.py b/api-docs/cppdocs/build_min_docs.py index 90d2aa2b..d9a56e1e 100644 --- a/api-docs/cppdocs/build_min_docs.py +++ b/api-docs/cppdocs/build_min_docs.py @@ -12,12 +12,11 @@ # make docset # =-=-- -__DOXYGEN_REQUIRED_VERSION__ = "1.12.0" - import argparse import os import sys import json +import re from collections import namedtuple import subprocess import shutil @@ -81,6 +80,45 @@ def load_items_in_file(filename): return items +def replace_getScript_function(js_content, replacement_func): + """ + Robustly find and replace the getScript function definition. + Uses brace counting to handle nested functions across different Doxygen versions. + """ + # Find the start of the function + pattern = r'const getScript\s*=\s*function\s*\([^)]*\)\s*\{' + match = re.search(pattern, js_content) + + if not match: + print("ERROR: getScript function not found in navtree.js") + sys.exit(1) + + start_pos = match.start() + func_start = match.end() - 1 # Position of opening brace + + # Count braces to find the matching closing brace + brace_count = 1 + pos = func_start + 1 + + while pos < len(js_content) and brace_count > 0: + if js_content[pos] == '{': + brace_count += 1 + elif js_content[pos] == '}': + brace_count -= 1 + pos += 1 + + if brace_count != 0: + print("ERROR: Could not find matching closing brace for getScript function") + sys.exit(1) + + end_pos = pos # Position after closing brace + + # Replace the function + new_content = js_content[:start_pos] + replacement_func + js_content[end_pos:] + + return new_content + + def minifier(): # Typically, doxygen's navbar will lazy load the data in all of these variables. @@ -115,12 +153,10 @@ def minifier(): # getScript(scriptName,func,show) here originally loads the js file and calls func once that is complete # Here, we just want to skip the whole process and immediately call the callback. + # This replacement works across different Doxygen versions (tested with 1.12.0, 1.14.0, and 1.15.0) nav_tree_fixed_get_script = "function getScript(scriptName,func,show) { func(); }" - navtree_before_get_script = navtree_orig.split("const getScript = function(scriptName,func) {")[0] - navtree_after_get_script = navtree_orig.split("const getScript = function(scriptName,func) {")[1].split('}', 1)[1] - - nav_tree_fixed = navtree_before_get_script + nav_tree_fixed_get_script + navtree_after_get_script + nav_tree_fixed = replace_getScript_function(navtree_orig, nav_tree_fixed_get_script) navtree = navtree_built_data + "\n" + nav_tree_fixed fp = open("html/navtree.js", "w") @@ -133,9 +169,6 @@ def build_doxygen(args): print('No Doxyfile found. Are you in the right directory?') sys.exit(1) _, vers, _ = system_with_output(f"{doxygen} -V") - if __DOXYGEN_REQUIRED_VERSION__ not in vers.strip(): - print(f'Please use Doxygen {__DOXYGEN_REQUIRED_VERSION__} to build documentation') - sys.exit(1) if args.docset: stat, _, _ = system_with_output("doxygen2docset --help") |
