Skip to content

Commit

Permalink
Fix generating C++ API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hericmar committed Mar 16, 2024
1 parent c051cf6 commit e450eea
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 16 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/deploy-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install dependencies
run: npm install
Expand All @@ -29,7 +32,7 @@ jobs:
wget https://github.com/matusnovak/doxybook2/releases/download/v1.5.0/doxybook2-linux-amd64-v1.5.0.zip
unzip doxybook2-linux-amd64-v1.5.0.zip
sudo cp bin/doxybook2 /usr/bin
# bash ./Scripts/CreateCppDocs.sh
bash ./Scripts/CreateCppDocs.sh
- name: Build website
run: npm run docs:build
Expand Down
3 changes: 1 addition & 2 deletions Docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default defineConfig({
// # Your title {#your-custom-id}
// ```
markdown: { attrs: { disable: true } },
ignoreDeadLinks: true,
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
Expand Down Expand Up @@ -59,7 +60,6 @@ export default defineConfig({
{ text: 'How to add new node', link: '/developer-guide/how-to-add-new-node' },
]
},
/*
{
text: 'C++ API Reference',
link: '/cpp-api-reference/',
Expand All @@ -70,7 +70,6 @@ export default defineConfig({
...autogenerate('Namespaces', 'namespaces'),
]
}
*/
],

socialLinks: [
Expand Down
2 changes: 1 addition & 1 deletion Docs/Doxygen/doxybook2.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"baseUrl": "/cpp-api-reference/",
"indexInFolders": true,
"linkLowercase": true,
"linkLowercase": false,
"linkSuffix": "",
"indexClassesName": "index",
"indexFilesName": "index",
Expand Down
56 changes: 48 additions & 8 deletions Scripts/CreateCppDocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,53 @@
# - doxygen
# - doxybook2

rm -rf Docs/Doxygen/xml
doxygen Docs/Doxygen/Doxyfile
MARKDOWN_DIR=Docs/cpp-api-reference

cd Docs
rm -rf cpp-api-reference && mkdir -p cpp-api-reference
doxybook2 --input Doxygen/xml --output cpp-api-reference --config Doxygen/doxybook2.json
cd -
function main() {
rm -rf Docs/Doxygen/xml
doxygen Docs/Doxygen/Doxyfile

# Replace <br>
# find Docs/cpp-api-reference -type f -name "*.md" | xargs sed -i 's/<br>//g'
rm -rf Docs/cpp-api-reference && mkdir -p "$MARKDOWN_DIR"
doxybook2 --input Docs/Doxygen/xml --output "$MARKDOWN_DIR" --config Docs/Doxygen/doxybook2.json

# Find Markdown files in the specified directory and escape < and > in them
find "$MARKDOWN_DIR" -type f -name "*.md" -print0 | while IFS= read -r -d '' file; do
echo "Correcting file: $file"
escaped_content=$(escape_markdown "$file")
echo "$escaped_content" > "$file"
done
}

# Function to escape < and > except within code blocks
function escape_markdown() {
python3 - $1 << 'EOF'
import re
import sys
def escape_markdown(text):
# Define a pattern to match code blocks
code_block_pattern = re.compile(r'```.*?```', re.DOTALL)
# Find code blocks and replace < and > inside them with placeholders
def escape_code_blocks(match):
code_block = match.group(0)
return code_block.replace('<', '\ufffe').replace('>', '\uffff')
# Replace < and > outside of code blocks
escaped_text = code_block_pattern.sub(escape_code_blocks, text)
escaped_text = escaped_text.replace('<', '&lt;').replace('>', '&gt;')
# Restore placeholders inside code blocks
escaped_text = escaped_text.replace('\ufffe', '<').replace('\uffff', '>')
return escaped_text
# Read Markdown file from "$file"
with open(sys.argv[1], 'r', encoding='utf-8') as file:
markdown_text = file.read()
escaped_text = escape_markdown(markdown_text)
print(escaped_text)
EOF
}

main
8 changes: 4 additions & 4 deletions Source/DIWNE/diwne_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ enum IconType
GrabDownRight,
Cross,
Hyphen,
Stop, ///<
Pause, ///< ⏸ two vertical bars
Stop, ///< Black Square For Stop (U+23F9)
Pause, ///< Double Vertical Bar (U+23F8)
SkipBack, ///< |< vertical bar followed by the left arrow
SkipBack2, ///< "<|" left arrow followed by the vertical bar
SkipForward, ///< ">|" right arrow followed by the vertical bar
SkipForward2, ///< |> vertical bar followed by the right arrow
Rewind, ///<
FastForward, ///<
Rewind, ///< Black Left-Pointing Double Triangle (U+23EA)
FastForward, ///< Black Right-Pointing Double Triangle (U+23E9)
AtFrom, // todo, now a synonym to the FastForward
AtTo, // todo, now a synonym to the Rewind
};
Expand Down

0 comments on commit e450eea

Please sign in to comment.