Giter Site home page Giter Site logo

andstor / jsdoc-action Goto Github PK

View Code? Open in Web Editor NEW
69.0 3.0 10.0 3.25 MB

:book: :octocat:GitHub Action to build JSDoc documentation

Home Page: https://github.com/marketplace/actions/jsdoc-action

License: Apache License 2.0

JavaScript 100.00%
github-actions jsdoc build documentation api docs

jsdoc-action's Introduction

jsdoc-action

A GitHub Action to build JSDoc documentation

This is a GitHub Action to build your JavaScript documentation with JSDoc. This action can easily be combined with other deployment actions, in order to publish the generated documentation to for example GitHub Pages. JSDoc templates are also supported.

The following example workflow step will generate documentation for all source files in the ./src directory and output the built files to the ./out directory.

- name: Build
  uses: andstor/jsdoc-action@v1
  with:
    source_dir: ./src
    recurse: true
    output_dir: ./out

Supported platforms

The jsdoc-action is a JavaScript action and is supported on both Linux, MacOS and Windows. The action supports stable versions of Node.js 14 and later.

OS (runs-on) ubuntu-latest macos-latest windows-latest
Support ✅️ ✅️ ✅️

Options ⚙️

The following input variables options can/must be configured:

Input variable Necessity Description Default
source_dir Optional Source directory to build documentation from.
output_dir Optional Output folder for the generated documentation. ./out
recurse Optional Recurse into subdirectories when scanning for source files. false
config_file Optional The path to a JSDoc configuration file.
template Optional The JSDoc template package to install. Will run npm install template.
template_dir Optional The relative location of the template files directory within the template package.
front_page Optional The path to a Markdown file to be used as a the front page. Normally README.md.

Templates 💅

You can use JSDoc templates with this action.
Just set the template input variable to the name of the template you want to use. This needs to be template's package name.

If the template's template files is located somewhere else than the package's root, you need to specify this. Set the template_dir input variable to the location of the template folder (contains a publish.js file).

For example, to use the JSDoc DocStrap template, set the template input variable to ink-docstrap and the template_dir to the string template.

JSDoc Configuration file 📄

To use a JSDoc configuration file located in your repository, you will need to specify the path to the file in the config_file input variable. Normally, if you use the actions/checkout, this will just resolve to conf.json or conf.js.

Examples

GitHub Pages 🚀

An example for deploying JSDoc generated documentation to GitHub Pages with actions-gh-pages.

This jsdoc-action workflow configuration uses the Minami JSDoc template and uses the root README.md file as the front page.

name: GitHub pages

on:
  push:
    branches:
      - master

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Build
        uses: andstor/jsdoc-action@v1
        with:
          source_dir: ./src
          output_dir: ./out
          config_file: conf.json
          template: minami
          front_page: README.md

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          publish_dir: ./out

License

Copyright © 2020 André Storhaug

The jsdoc-action GitHub action is licensed under the Apache License, Version 2.0.
See the LICENSE file for more information.

jsdoc-action's People

Contributors

andstor avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jsdoc-action's Issues

Error: Cannot find module 'escape-string-regexp'

Hi @andstor -- thanks much for the plugin! Wondering if you might be able to take a look at this config/error?

name: JSDoc

on: [pull_request]

jobs:
  install:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Build
        uses: andstor/[email protected]
        with:
          source_dir: ./src/modules
          output_dir: ./out
          template: minami
          front_page: README.md

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          publish_dir: ./out
📝 Generating documentation
/usr/local/bin/node /home/runner/work/_actions/andstor/jsdoc-action/v1.0.2/node_modules/jsdoc/jsdoc.js /home/runner/work/iron/iron/src/modules -r -R /home/runner/work/iron/iron/README.md -d /home/runner/work/iron/iron/out
internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module 'escape-string-regexp'
Require stack:
- /home/runner/work/_actions/andstor/jsdoc-action/v1.0.2/node_modules/jsdoc/lib/jsdoc/name.js
- /home/runner/work/_actions/andstor/jsdoc-action/v1.0.2/node_modules/jsdoc/lib/jsdoc/app.js
- /home/runner/work/_actions/andstor/jsdoc-action/v1.0.2/node_modules/jsdoc/jsdoc.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Requizzle.requizzle (/home/runner/work/_actions/andstor/jsdoc-action/v1.0.2/node_modules/requizzle/lib/requizzle.js:84:29)
    at infectProxy (/home/runner/work/_actions/andstor/jsdoc-action/v1.0.2/node_modules/requizzle/lib/loader.js:79:31)
    at Module.targetModule.require (/home/runner/work/_actions/andstor/jsdoc-action/v1.0.2/node_modules/requizzle/lib/loader.js:97:44)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/home/runner/work/_actions/andstor/jsdoc-action/v1.0.2/node_modules/jsdoc/lib/jsdoc/name.js:6:16)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Object.load (/home/runner/work/_actions/andstor/jsdoc-action/v1.0.2/node_modules/requizzle/lib/loader.js:105:18) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/runner/work/_actions/andstor/jsdoc-action/v1.0.2/node_modules/jsdoc/lib/jsdoc/name.js',
    '/home/runner/work/_actions/andstor/jsdoc-action/v1.0.2/node_modules/jsdoc/lib/jsdoc/app.js',
    '/home/runner/work/_actions/andstor/jsdoc-action/v1.0.2/node_modules/jsdoc/jsdoc.js'
  ]
}
Error: The process '/usr/local/bin/node' failed with exit code 1

What's the best way to use a custom domain with GitHub Pages?

Hello,
I'm using your action for my repository. Here is my current workflow:

name: GitHub pages

on:
  push:
    branches:
      - master

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Build
        uses: andstor/jsdoc-action@v1
        with:
          source_dir: ./src
          output_dir: ./docs
          config_file: .jsdoc.json
          template_name: Androz2091/minami
          front_page: README.md

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          personal_token: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          publish_dir: ./docs

So as you can see, I'm building the docs with your action, and then deploying them with actions-gh-pages. The problem is that GitHub Pages doesn't use my custom domain name (if I add a CNAME to the gh-pages branch, it's overwritten each time). So, what is the best way to support a custom domain? Committing the CNAME file to my master branch and (I couldn't find how) tell to jsdoc to keep this file in the output directory? Or adding an option "cname: custom-domain.com" to your action, so your script adds a CNAME file with the domain name?
I don't know, if you could give me more information and what you think, thank you.

Unable to find the source file or directory /home/runner/work/_actions/andstor/jsdoc-action/v1/app/js

My action file looks as follows, based on your example for github pages:

name: GitHub pages

on:
  push:
    branches:
      - master

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Build
        uses: andstor/jsdoc-action@v1
        with:
          source_dir: ./app
          output_dir: ./docs/test
          config_file: jsdoc.json
          template_name: docdash
          front_page: README.md

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          publish_dir: ./docs/test

If executed it fails in the Build section, see the following log:

Run andstor/jsdoc-action@v1
  with:
    source_dir: ./app
    output_dir: ./docs/test
    config_file: jsdoc.json
    template_name: docdash
    front_page: README.md
    recurse: true
Installing JSDoc template: docdash
/usr/local/bin/npm install docdash --production
+ [email protected]
added 3 packages from 3 contributors and audited 882321 packages in 7.954s
found 0 vulnerabilities

📝 Generating documentation
/usr/local/bin/node /home/runner/work/_actions/andstor/jsdoc-action/v1/node_modules/jsdoc/jsdoc.js /home/runner/work/media-dupes/media-dupes/app -r -c /home/runner/work/media-dupes/media-dupes/jsdoc.json -t node_modules/docdash -R /home/runner/work/media-dupes/media-dupes/README.md -d /home/runner/work/media-dupes/media-dupes/docs/test
ERROR: Unable to find the source file or directory /home/runner/work/_actions/andstor/jsdoc-action/v1/app/js
ERROR: Unable to find the source file or directory /home/runner/work/_actions/andstor/jsdoc-action/v1/main.js
Parsing /home/runner/work/media-dupes/media-dupes/app/js/modules/crashReporter.js ...
Parsing /home/runner/work/media-dupes/media-dupes/app/js/modules/ffmpeg.js ...
Parsing /home/runner/work/media-dupes/media-dupes/app/js/modules/githubUrls.js ...
Parsing /home/runner/work/media-dupes/media-dupes/app/js/modules/sentry.js ...
Parsing /home/runner/work/media-dupes/media-dupes/app/js/modules/settings.js ...
Parsing /home/runner/work/media-dupes/media-dupes/app/js/modules/ui.js ...
Parsing /home/runner/work/media-dupes/media-dupes/app/js/modules/unhandled.js ...
Parsing /home/runner/work/media-dupes/media-dupes/app/js/modules/utils.js ...
Parsing /home/runner/work/media-dupes/media-dupes/app/js/modules/youtubeDl.js ...
Parsing /home/runner/work/media-dupes/media-dupes/app/js/renderer.js ...
Generating output files...
Finished running in 0.99 seconds.
##[error]The process '/usr/local/bin/node' failed with exit code 1

Any idea about this issue? Is that an error from me?

GitHub Pages example gives code error

Getting an error when copy pasting the GitHub Pages example code:

Invalid Workflow File
every step must define a `uses` or `run` key

Seems that there is a typo in the example workflow code.

Need to remove the hyphen in - uses: actions/checkout@v2.
There should only be one per step.

Methods/Functions are mentioned several times

While i now have your action running i am starting to check the resulting output. At least for me it looks like my module functions are mentioned several times in the resulting html output.

Example output:
https://yafp.github.io/media-dupes/module-ffmpeg.html

Related js source file:
https://github.com/yafp/media-dupes/blob/master/app/js/modules/ffmpeg.js

Related jsdoc config file:
https://github.com/yafp/media-dupes/blob/master/jsdoc.json

Related action:
https://github.com/yafp/media-dupes/actions?query=workflow%3A%22GitHub+pages%22

This does not happens if i generate them manually.

Any idea what might cause this?

Output folder created, but nothing shows up in the repo after workflow finishes

Hello, I set up a simple GitHub repo with a Javascript file that I'm using to test out your tool, and I'm having an issue with no output showing up in the repo afterward. I'm following the example you provided, omitting the deployment section

Unless I'm misunderstanding something, I'm assuming it will save the result in the repo with the output_dir given.

If I did misunderstand and its not intended to save the results to the GitHub repo itself, would you happen to know a way of saving it to master without needing to manually upload a saved artifact?

Willing to test

Hi,

i am interested in this project. Feel free to query me if you got your first version running.

How to use a github repo as template?

Hello,
I forked the minami repository. The package URL is now Androz2091/minami. It's successfully installed:

Capture d’écran 2020-04-19 à 10 35 00

But, the package name is still "minami", not "Androz2091/minami". So the package is not found in the node_modules folder.

This problem concerns every template published on github, as the npm package name is AUTHOR/TEMPLATE_NAME. Maybe if the template_name includes a /, it would be possible to split on it and to keep the second string...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.