Skip to content

Commit

Permalink
fix readme for doxygen
Browse files Browse the repository at this point in the history
  • Loading branch information
matekelemen committed Aug 7, 2024
1 parent 54004b6 commit 934533e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
!.gitignore
!doxyfile
!doxygen-awesome.css
!prepareDocs.py
40 changes: 40 additions & 0 deletions docs/prepareDocs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# The main readme.md at the repository's root is used as the landing
# page of the doxygen documentation, which becomes an issue when
# resolving links (github vs local docs). This script creates a
# separate readme.md for doxygen and replaces the links to point to
# local or github links, depending in the provided arguments.

# --- STD Imports ---
import pathlib
import re
import argparse


parser = argparse.ArgumentParser("prepareDocs")
parser.add_argument("-w",
dest = "web",
action = "store_const",
const = True,
default = False,
help = "prepare docs for the web")
arguments = parser.parse_args()

rootPath = "https://matekelemen.github.io/mcgs/" if arguments.web else "../../"
docPath = rootPath + "docs/html/"
assetPath = rootPath + ".github/assets/"

docLinkPattern = re.compile(r"\[mcgs::(\w+)\]\(([\w0-9\.#]+)\)")
docLinkReplace = r"[mcgs::\1](" + docPath + r"\2)"
assetLinkPattern = re.compile(r"\.github/assets/")
assetLinkReplace = assetPath

readme = ""
with open(pathlib.Path(__file__).absolute().parent.parent / "readme.md", "r") as inputFile:
readme = inputFile.read()

with open(pathlib.Path(__file__).parent / "readme.md", "w") as outputFile:
outputFile.write(re.sub(assetLinkPattern,
assetLinkReplace,
re.sub(docLinkPattern,
docLinkReplace,
readme)))

0 comments on commit 934533e

Please sign in to comment.