Skip to content

Commit

Permalink
Merge pull request #21 from projectdiscovery/new-js-docs
Browse files Browse the repository at this point in the history
feat: new doc generator using typescript files
  • Loading branch information
tarunKoyalwar authored Feb 8, 2024
2 parents bfcda57 + 415f216 commit 5615709
Show file tree
Hide file tree
Showing 99 changed files with 8,335 additions and 1,990 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build-js-proto-docs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build JS Protocol Docs
name: Build JS Proto Modules Docs

on:
schedule:
Expand All @@ -16,11 +16,14 @@ jobs:
- name: Setup Node Environment
uses: actions/[email protected]

- name: Install jsdoc-to-markdown
run: npm install -g jsdoc-to-markdown
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x

- name: Build JS Proto Docs
run: ./bin/jsdocs.sh
run: ./generate.sh
working-directory: static/docsbuilder

- name: Commit results to Github
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.DS_Store
./nuclei/
/static/docsbuilder/node_modules/
/static/docsbuilder/src/
2 changes: 0 additions & 2 deletions mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@
"pages": [
"templates/protocols/javascript/modules/bytes",
"templates/protocols/javascript/modules/fs",
"templates/protocols/javascript/modules/global",
"templates/protocols/javascript/modules/goconsole",
"templates/protocols/javascript/modules/ikev2",
"templates/protocols/javascript/modules/kerberos",
"templates/protocols/javascript/modules/ldap",
Expand Down
59 changes: 59 additions & 0 deletions static/docsbuilder/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
printf "\n\e[32m[*] Updating Nuclei Javascript Modules ...\e[0m\n"
# clone nuclei
git clone https://github.com/projectdiscovery/nuclei.git
# branch
export BRANCH=issue-4248-ts-docs

# change directory
cd nuclei
# checkout to branch
git checkout $BRANCH

# generate documentation
printf "\n\e[32m[*] Generating Typescript Files ...\e[0m\n"
# generate typescript files
make ts
cd .. # change directory to root

# copy typescript files
printf "\n\e[32m[*] Copying Typescript Files ...\e[0m\n"
cp -r nuclei/pkg/js/generated/ts src

# setup typescript project
printf "\n\e[32m[*] Download Typescript project dependencies ...\e[0m\n"
npm install

# run npm run build
printf "\n\e[32m[*] Building Nuclei Typescript Modules ...\e[0m\n"
npm run build

# generate docs
printf "\n\e[32m[*] Generate documentation ...\e[0m\n"
npm run docs


# post processing (rename .md to .mdx and remove .md in links)
printf "\n\e[32m[*] Post Processing ...\e[0m\n"

# rename .md to .mdx
cd docs
printf "\n\e[32m[*] Change extension from .md to .mdx ...\e[0m\n"
for file in *.md; do mv "$file" "${file%.md}.mdx"; done

# remove .md in links
printf "\n\e[32m[*] Remove .md in links ...\e[0m\n"
sed -i '' 's/\.md//g' *.mdx

# move to appropriate directory
cd ../../.. #project root
mv static/docsbuilder/docs/* templates/protocols/javascript/modules/

# remove nuclei
printf "\n\e[32m[*] Cleanup ...\e[0m\n"
rm -rf static/docsbuilder/nuclei
rm -rf static/docsbuilder/docs
rm -rf static/docsbuilder/src
rm -rf static/docsbuilder/node_modules

# done
printf "\n\e[32m[*] Done\e[0m\n"
223 changes: 223 additions & 0 deletions static/docsbuilder/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions static/docsbuilder/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "nuclei",
"version": "1.0.0",
"description": "Nuclei Javascript protocol Modules",
"main": "index.js",
"types": "./index.d.ts",
"exports": {
".": "./index.js"
},
"scripts": {
"build": "tsc",
"docs": "node_modules/typedoc/bin/typedoc --plugin typedoc-plugin-markdown --plugin typedoc-github-wiki-theme --out docs --publicPath '/templates/protocols/javascript/modules/' src/index.ts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/projectdiscovery/nuclei-js-types.git"
},
"keywords": [
"nuclei",
"js",
"protocol",
"types"
],
"author": "projectdiscovery",
"license": "MIT",
"bugs": {
"url": "https://github.com/projectdiscovery/nuclei-js-types/issues"
},
"homepage": "https://github.com/projectdiscovery/nuclei-js-types#readme",
"devDependencies": {
"typedoc": "^0.25.7",
"typedoc-github-wiki-theme": "^1.1.0",
"typedoc-plugin-markdown": "^3.17.1"
}
}
16 changes: 16 additions & 0 deletions static/docsbuilder/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
// "outDir": "./", // Output directory for all emitted files
// "declaration": true, // Generates corresponding '.d.ts' file
// "declarationDir": "./", // Output directory for declaration files
"rootDir": "./src", // Specifies the root directory of input files
// ... other options like "module", "target", etc.
},
"include": [
"src/**/*.ts" // Include all TypeScript files in the src folder
],
"exclude": [
"node_modules", // Exclude the node_modules folder
"**/*.test.ts" // Exclude test files
]
}
Loading

0 comments on commit 5615709

Please sign in to comment.