Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Autogenerated API Documentation #110

Merged
merged 13 commits into from
Feb 11, 2020
Merged

Autogenerated API Documentation #110

merged 13 commits into from
Feb 11, 2020

Conversation

yosriady
Copy link

@yosriady yosriady commented Feb 10, 2020

Closes #87 and unblocks #86

This PR adds a new npm run docs command to generate API and type documentation for the COMIT JS SDK. The docs command generates HTML in the docs/ directory (gitignored) to be embedded later in the main Docusaurus site.

About

Unfortunately, neither documentation.js and esdoc are compatible with our requirements around handwritten documentation and Typescript - despite repeated attempts at making it work and custom configuration.

The good news is we can get it done with Typedoc.

Getting Started

npm install
npm run docs

Your browser should automatically open the index.html file.

This PR also supports Markdown generation. To generate Markdown instead of HTML, do:

npm run docs:md

Screenshots

Screenshot 2020-02-10 at 11 28 20 AM

Screenshot 2020-02-10 at 11 28 01 AM

Screenshot 2020-02-10 at 11 29 25 AM

Annotating SDK Code

You can see an example annotated file in tokens/tokens.ts. You can use the following tags:

  • @description
  • @params
  • @returns

Screenshot 2020-02-10 at 11 03 58 AM

The above snippet will result in:

Screenshot 2020-02-10 at 11 03 39 AM

Check this out for more information on what tags are supported.

Advanced Configuration

In typedoc.json, you can configure the generation parameters:

{
  "inputFiles": ["./src"],
  "mode": "modules",
  "out": "docs",
  "exclude": "**/*+(index|.spec|.e2e|.d).ts",
  "tsconfig": "./tsconfig.json",
  "includeDeclarations": true,
  "excludeExternals": true,
  "excludeNotExported": false,
  "excludePrivate": true,
  "excludeProtected": false,
  "ignoreCompilerErrors": false,
  "media": "TODO",
  "includes": "TODO, include for literate style documentation",
  "theme": "default",
  "includeVersion": true,
  "readme": "README.md",
  "categorizeByGroup": false,
  "defaultCategory": "Other",
  "hideGenerator": true
}
  • theme can be default which is a multi-page HTML project or minimal which is a single HTML file for easy embedding.
  • includes allow us to insert snippets of documentation in between the generated HTML for a more 'literate programming' style of documentation

Check this out for details on configuration options.

Next Steps

  • (Team) Clone this branch and give feedback on the output.
  • (Team) Annotate the rest of the JS SDK.
  • (Yos) Embed the HTML on a Docusaurus page.

@mergify
Copy link
Contributor

mergify bot commented Feb 10, 2020

Are you sure the changelog does not need updating?

@claassistantio
Copy link

claassistantio commented Feb 10, 2020

CLA assistant check
All committers have signed the CLA.

@yosriady
Copy link
Author

Please feel free to share your feedback or ask any questions here.

Copy link
Member

@da-kami da-kami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gave it a try, like it :)

Copy link

@D4nte D4nte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job. I love the links to Github repo.

@mergify mergify bot merged commit 7210cb6 into master Feb 11, 2020
@mergify mergify bot deleted the feature/typedoc branch February 11, 2020 02:58
@yosriady
Copy link
Author

Perfect. I'll proceed with embedding this API doc on the https://comit.network Docusaurus site.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Markdown generation from JSDoc comments
4 participants