Created
February 6, 2024 16:29
-
-
Save pedro-psb/b933a5abce2797b939c230b4d4020cd1 to your computer and use it in GitHub Desktop.
Create pulp-docs structure, convert to markdown and do some conversion cleaning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 1. create structure | |
mkdir -p \ | |
staging_docs/{admin,user,dev}/{guides,tutorials,learn} \ | |
staging_docs/reference | |
cp -r docs tmp_docs | |
# 2. convert to rst->markdown (optional) | |
pip install rst-to-myst[sphinx] | |
find tmp_docs -name '*.rst' -exec rst2myst convert --replace-files {} ';' | |
# 3. extra automated cleaning | |
DOCDIR=tmp_docs | |
find $DOCDIR -type f -name "*.md" -exec sed -i -e 's/:::{note}/!!! note/' {} ';' | |
find $DOCDIR -type f -name "*.md" -exec sed -i -e 's/:::{tip}/!!! tip/' {} ';' | |
find $DOCDIR -type f -name "*.md" -exec sed -i -e 's/:::{warning}/!!! warning/' {} ';' | |
find $DOCDIR -type f -name "*.md" -exec sed -i -e 's/:::{hint}/!!! tip/' {} ';' | |
find $DOCDIR -type f -name "*.md" -exec sed -i -e 's/:::{glossary}//' {} ';' | |
find $DOCDIR -type f -name "*.md" -exec sed -i -e 's/{term}//' {} ';' | |
find $DOCDIR -type f -name "*.md" -exec sed -i -e 's/{github}//' {} ';' | |
find $DOCDIR -type f -name "*.md" -exec sed -i -e 's/{ref}//' {} ';' | |
find $DOCDIR -type f -name "*.md" -exec sed -i -re 's/^\([a-zA-Z-]+\)=$//' {} ';' # remove (something)= | |
find $DOCDIR -type f -name "*.md" -exec sed -i -re 's/`([a-zA-Z ]*)<\w*>`/`\1`/' {} ';' # remove `some thing <RemoveThis>` | |
find $DOCDIR -type f -name "*.md" -exec sed -i -e 's/:::$//' {} ';' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment