Skip to content

Commit

Permalink
Merge pull request #1 from wise-king-sullyman/extend-in-code-document…
Browse files Browse the repository at this point in the history
…ation

feat(docs): Add in code documentation for things other than props
  • Loading branch information
wise-king-sullyman authored Mar 28, 2023
2 parents 45ddef1 + 309a3ed commit 17f63b1
Show file tree
Hide file tree
Showing 6 changed files with 730 additions and 14 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"version": "detect"
}
},
"plugins": ["react", "react-hooks", "@typescript-eslint"],
"plugins": ["react", "react-hooks", "@typescript-eslint", "patternfly-react"],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "error",
Expand All @@ -53,7 +53,9 @@
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-var-requires": "off",
"arrow-body-style": "error",
"@typescript-eslint/no-unnecessary-type-constraint": "off",
"@typescript-eslint/no-empty-function": "off",
"arrow-body-style": "off",
"camelcase": [
"error",
{
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/deploy-typedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "Upload GitHub Pages artifact"
description: "A composite action that prepares your static assets to be deployed to GitHub Pages"
author: "GitHub"
inputs:
name:
description: 'Artifact name'
required: false
default: 'github-pages'
path:
description: "Path of the directory containing the static assets."
required: true
default: "/docs"
retention-days:
description: "Duration after which artifact will expire in days."
required: false
default: "1"
runs:
using: composite
steps:
- name: Archive artifact
shell: sh
if: runner.os == 'Linux'
run: |
chmod -c -R +rX "$INPUT_PATH" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
tar \
--dereference --hard-dereference \
--directory "$INPUT_PATH" \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
.
env:
INPUT_PATH: ${{ inputs.path }}

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.name }}
path: ${{ runner.temp }}/artifact.tar
retention-days: ${{ inputs.retention-days }}
if-no-files-found: error
71 changes: 70 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,76 @@ on:
jobs:
call-build-lint-test-workflow:
uses: ./.github/workflows/build-lint-test.yml
deploy:
build-typedocs:
runs-on: ubuntu-latest
needs: [call-build-lint-test-workflow]
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14'
- uses: actions/cache@v2
id: yarn-cache
name: Cache npm deps
with:
path: |
node_modules
**/node_modules
~/.cache/Cypress
key: ${{ runner.os }}-yarn-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
- run: yarn install --frozen-lockfile
if: steps.yarn-cache.outputs.cache-hit != 'true'
- uses: actions/cache@v2
id: dist
name: Cache dist
with:
path: |
packages/*/dist
packages/react-styles/css
key: ${{ runner.os }}-dist-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('yarn.lock', 'package.json', 'packages/*/*', '!packages/*/dist', '!packages/*/node_modules') }}
- name: Build dist
run: yarn build
if: steps.dist.outputs.cache-hit != 'true'
- name: Build typedocs
run: yarn build:typedocs
- name: Archive artifact
shell: sh
run: |
chmod -c -R +rX "$INPUT_PATH" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
tar \
--dereference --hard-dereference \
--directory "$INPUT_PATH" \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
.
env:
INPUT_PATH: docs
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: github-pages
path: ${{ runner.temp }}/artifact.tar
retention-days: 1
if-no-files-found: error
deploy-typedocs:
runs-on: ubuntu-latest
needs: [call-build-lint-test-workflow, build-typedocs]
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
deploy-package:
runs-on: ubuntu-latest
needs: [call-build-lint-test-workflow]
env:
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"build": "yarn workspace @patternfly/react-topology build",
"build:docs": "yarn workspace @patternfly/react-topology docs:build",
"build:fed:packages": "yarn workspace @patternfly/react-topology build:fed:packages",
"build:typedocs": "node typeDocGen.js",
"start": "yarn build && concurrently --kill-others \"yarn workspace @patternfly/react-topology docs:develop\"",
"serve:docs": "yarn workspace @patternfly/react-topology docs:serve",
"clean": "yarn workspace @patternfly/react-topology clean",
Expand All @@ -35,6 +36,7 @@
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-patternfly-react": "^4.80.4",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"prettier": "2.7.1",
Expand All @@ -49,7 +51,8 @@
"@testing-library/user-event": "13.5.0",
"@testing-library/jest-dom": "5.16.5",
"jest-environment-jsdom": "^29.2.2",
"serve": "^14.1.2"
"serve": "^14.1.2",
"typedoc": "0.23"
},
"resolutions": {
"@types/react": "17^"
Expand Down
36 changes: 36 additions & 0 deletions typeDocGen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const TypeDoc = require("typedoc");
const path = require('path');

async function typeDocGen(entryPoint, tsconfigLocation) {
const app = new TypeDoc.Application();

// If you want TypeDoc to load tsconfig.json / typedoc.json files
app.options.addReader(new TypeDoc.TSConfigReader());
app.options.addReader(new TypeDoc.TypeDocReader());

app.bootstrap({
// typedoc options here
entryPointStrategy: 'expand',
entryPoints: [entryPoint],
tsconfig: tsconfigLocation
});

const project = app.convert();

if (project) {
// Project may not have converted correctly
const outputDir = "docs";

// Rendered docs
await app.generateDocs(project, outputDir);
// Alternatively generate JSON output
// await app.generateJson(project, outputDir + "/documentation.json");
}
}

const packageBase = require.resolve('@patternfly/react-topology').replace('dist/esm/index.js', '')
const entry = path.relative(process.cwd(), path.join(packageBase, 'src'))
const configLocation = path.relative(process.cwd(), path.join(packageBase, 'tsconfig.json'))

typeDocGen(entry, configLocation).catch(console.error);

Loading

0 comments on commit 17f63b1

Please sign in to comment.