Giter Site home page Giter Site logo

vad1ym / vitepress-jsdoc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ph1p/vuepress-jsdoc

0.0 0.0 0.0 6.22 MB

Build JSDoc markdown files for vitepress

Home Page: https://vuepress-jsdoc-example.vercel.app/

License: MIT License

Shell 0.10% JavaScript 32.83% TypeScript 44.80% Handlebars 1.73% Vue 20.55%

vitepress-jsdoc's Introduction

vuepress-jsdoc

Quality Gate Status npm vercel

This npm package is a command line script, which scans your JavaScript, Vue or Typescript source code and generates markdown files for vuepress with the help of jsdoc-to-markdown and vue-docgen-cli.

CLI ./example

How to

yarn global add vuepress-jsdoc
npm i vuepress-jsdoc -g

Example:

# search code in src and move it to code (./documentation/code) in your vuepress folder (./documentation)
vuepress-jsdoc --source ./src --dist ./documentation --folder code --title API --exclude="**/*/*.test.js"

You can also use npx vuepress-jsdoc, if you want.

Plugin (Dev-Mode) alpha

You can use vuepress-jsdoc also as plugin. This plugin watches you generated files.

// ./documentation/.vuepress/config.js
plugins: [
  [
    require('vuepress-jsdoc').default,
    {
      folder: 'code',
      source: './dist',
      dist: './documentation',
      title: 'API',
      partials: ['./example/partials/*.hbs'],
      readme: './README.md',
      exclude: '**/*.d.ts,**/interfaces.*,**/constants.*,**/cmds.*'
    }
  ]
];

Watch-Mode alpha

If you do not want to runvuepress-jsdoc again and again and again. You can simply pass --watch or -w.

Command-Options

Use these options after vuepress-jsdoc.

Name Alias Default Description
--source -s ./src Source folder with .js or .ts files
--dist -d ./documentation Destination folder
--folder -f ./code Folder inside destination folder. Gets overwritten everytime
--title -t API Title of your documentation
--help -h Show help
--version -v Show current version
--readme -r Path to custom readme file
--exclude -e Pattern to exclude files/folders (Comma seperated) - *.test.js,exclude.js more information
--include -e Pattern to include files/folders (Comma seperated) - *.test.js,exclude.js more information
--rmPattern -rm Pattern when removing files. You can ex- and include files. (glob pattern)
--partials -p jsdoc2markdown partial templates (overwrites default ones)
--jsDocConfigPath -c Path to JsDoc Config (experimental)
--watch -w Watch changes and update markdown files

config.js

Inside your generated folder, you can find a config.js. This file includes a complete filetree and an vuepress sidebar tree.

How to configure vuepress

Vuepress is a static site generator by Evan You. You can add all generated documentation files to your existing vuepress project or create a new one.

# First install vuepress
yarn global add vuepress

# Run the CLI
vuepress-jsdoc

# Run vuepress dev server
vuepress dev ./documentation

# Run vuepress build, if you want to ship it
vuepress build ./documentation

Access it via: http://localhost:8080/code/

Now you need the sidebar. Create a .vuepress folder inside the documentation folder and add the following config.js.

config.js:

// auto generated sidebar
const { sidebarTree } = require('../code/config');

module.exports = {
  dest: 'dist',
  locales: {
    '/': {
      title: 'vuepress-jsdoc',
      description: 'Generate jsdoc markdown files for vuepress'
    }
  },
  themeConfig: {
    editLinks: true,
    sidebarDepth: 4,
    docsDir: 'code',
    locales: {
      '/': {
        nav: [
          {
            text: 'Home',
            link: '/'
          }
        ],
        // Add the generated sidebar
        sidebar: Object.assign({}, sidebarTree('Mainpage title'))
      }
    }
  }
};

Custom readme

You can easily add a custom path to your readme by using the --readme ./path/to/file.md parameter. If you move a README.md inside your source folder, it should resolve it automatically. You can set the title by passing it to the sidebarTree('Mainpage title') function inside your ./.vuepress/config.js.

@vuepress comment block

You can add custom meta data to your pages by using the @vuepress block:

/*
 * @vuepress
 * ---
 * title: Your custom title
 * headline: You custom headline
 * ---
 */

Use headline to add a custom h1 title.

More information

Typescript

To use typescript, you have to install these dev-dependencies:

npm install -D typescript jsdoc-babel @babel/cli @babel/core @babel/preset-env @babel/preset-typescript jsdoc-to-markdown

Next, you have to add a jsdoc.json to your project with some settings and add it with the -c parameter. You can find a full working example with all settings inside the ./example folder. The example shows also how to use babel-plugins.

Example

The ./example folder includes a full working vuepress-jsdoc example.

# Install dependencies
npm install

# Run the CLI
vuepress-jsdoc

# Generate docs
npm run docs

# Run dev server
npm run dev

# Generate dist folder
npm run build

Contribute

PRs are always welcome (:

vitepress-jsdoc's People

Contributors

ph1p avatar henrytabima avatar dependabot[bot] avatar juliushaertl avatar greenimp avatar codacy-badger avatar narration-sd avatar nriesco avatar rck-dev-bot avatar

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.