Skip to content

Commit

Permalink
docs: flattening output files for typedoc
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck committed May 24, 2024
1 parent da77deb commit 34225e4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,20 @@ jobs:
- name: Build Typedoc
run: npm run typedoc

- name: Update markdown files
run: |
cd docs
../scripts/adjustMarkdown.sh
- name: Build example markdown
run: node scripts/generateExample.mjs

- name: Final Adjustment to files
run: |
mv docs/packages.md docs/HOME.md
mv docs/EXAMPLES.md .
rm -rf docs/index.md docs/docs.json
- name: Sync Wiki to Docs
uses: newrelic/wiki-sync-action@main
with:
Expand All @@ -53,16 +64,8 @@ jobs:
gitAuthorEmail: github-actions@github.com
branch: main

- name: Upload Documentation to Wiki
uses: SwiftDocOrg/github-wiki-publish-action@v1
with:
path: "docs"
env:
GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_TOKEN_COMMIT }}

- name: Copy and commit example markdown
run: |
cp docs/EXAMPLES.md .
git config --local user.name github-actions
git config --local user.email github-actions@github.com
git add EXAMPLES.md
Expand Down
22 changes: 22 additions & 0 deletions scripts/adjustMarkdown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Adjusts the markdown files to remove relative links
## Since we want all the files to be named after the module, this will make
## those adjustments.
find . -type d | while read dir; do
# URL encode the file without spaces
ESCAPED_FILE=$(echo "$dir.md" | tail -c+3 | sed 's/ /-/g')
FILE=$(echo "$dir/globals.md")
if [[ -e "$FILE" ]]
then
echo "Adjusting $FILE"
(cd "$dir" &&
# Adjust all relative links back up to the root
sed -E 's/\(\.\.\/(.+)(\/globals\.md)(.+)\)/(.\/\1\3)/g' globals.md |
# Adjust all references to packages.md to HOME.md
sed -E 's/\(..\/packages.md\)/(\.\/HOME)/g' |
# Adjust all local references to new file name
sed -E "s/\(globals\.md(.+)\)/(\.\/$ESCAPED_FILE)/g" >> "$dir.md"
)
(cd "$dir" && rm -rf globals.md index.md)
fi
done
echo "END OF LINE"
6 changes: 5 additions & 1 deletion typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"entryPointStrategy": "packages",
"outputFileStrategy": "modules",
"flattenOutputFiles": true,
"mergeReadme": true,
"mergeReadme": false,
"entryFileName": "index",
"excludeScopesInPaths": true,
"enumMembersFormat": "table",
"useCodeBlocks": true,
"entryPoints": [
"packages/*"
],
Expand Down

0 comments on commit 34225e4

Please sign in to comment.