From 05df5d5502df0355c6940ea817c9685e73999e8f Mon Sep 17 00:00:00 2001 From: Timo Koch <timok@simula.no> Date: Wed, 5 Mar 2025 21:33:05 +0100 Subject: [PATCH] [doxygen] Adds and edit button to markdown file on GitLab --- doc/doxygen/dumux-custom.css | 15 +++++++++++++++ doc/doxygen/markdown-filter.py | 25 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/doc/doxygen/dumux-custom.css b/doc/doxygen/dumux-custom.css index db7c058167..c741e5dd1c 100644 --- a/doc/doxygen/dumux-custom.css +++ b/doc/doxygen/dumux-custom.css @@ -24,6 +24,21 @@ height:60px; margin-bottom:-4px } +.edit-button { + display: inline-block; + padding: 5px 10px 5px 10px; + background: #ffaa16; + border-radius: 10px; + color: black; + vertical-align: middle; +} +.edit-button:hover { + background: #ffcc1d; +} +a.edit-button{ + text-decoration: none !important; + color: black !important; +} .cls-r-1{ fill:#dd1f26 } diff --git a/doc/doxygen/markdown-filter.py b/doc/doxygen/markdown-filter.py index 6820be33fe..e6911cb1d0 100644 --- a/doc/doxygen/markdown-filter.py +++ b/doc/doxygen/markdown-filter.py @@ -16,6 +16,19 @@ MAIN_README = abspath(join(TOP_LEVEL_DIR, "README.md")) assert exists(MAIN_README) +def _get_file_gitlab_url(path: str) -> str: + return ( + "https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/" + "-/blob/master/" + f"{path}" + "?ref_type=heads" + ) + + +def _file_path_relative_to_top_level(path: str) -> str: + return path.replace(TOP_LEVEL_DIR, "").lstrip("/") + + def _filter_characters(text: str) -> str: return "".join(filter(lambda c: c not in string.punctuation and c not in string.digits, text)) @@ -69,5 +82,17 @@ for line in result.split("\n"): line if verbatim_environment else _enable_doxygen_only_content(_add_header_label(line)) ) +# Tell readers that they can edit the markdown content on GitLab + +markdown_file_path = _file_path_relative_to_top_level(filePath) +file_url = _get_file_gitlab_url(markdown_file_path) + +result_lines.extend( + [ + "\n----\n", + f'<a class="edit-button" href="{file_url}">' "🛠Edit above doc on GitLab" "</a>\n", + ] +) + # Print the final result for Doxygen to pick it up print("\n".join(result_lines)) -- GitLab