• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

dineshsonachalam/markdown-autodocs: ✨ A GitHub Action that automatically genera ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

dineshsonachalam/markdown-autodocs

开源软件地址(OpenSource Url):

https://github.com/dineshsonachalam/markdown-autodocs

开源编程语言(OpenSource Language):

JavaScript 74.8%

开源软件介绍(OpenSource Introduction):

A GitHub Action that automatically generates & updates markdown content (like your README.md) from external or remote files.

npm version MIT License

Ask questions in the GitHub issues

Table of contents

Why markdown-autodocs

To make your repo more appealing and useful you need to provide example code snippets in your README.md. Manually copy and pasting each code snippet in their respective places in your README would be inefficient and time-consuming.

This problem can be solved using markdown-autodocs a GitHub Action that automatically generates & updates markdown content (like your README.md) from external or remote files. You need to add markers in your README.md that will tell markdown-autodocs where to insert the code snippet.

Features

  • Code block: Insert code snippet in your markdown file from external or remote files.
  • JSON to HTML table: Insert HTML Table in your markdown file by converting JSON file contents to HTML table.
  • Github Workflow Artifacts table: Insert the Github workflow artifacts table in your markdown file by getting the latest artifacts for a workflow run.

Examples

CODE Block

Get code from an external file or URL and insert it in your markdown.

Options:

  • src: The relative path to the code to pull in, or the URL where the raw code lives
  • lines (optional): a range with lines of code which will then be replaced with code from the file. The line range should be defined as: "lines=startLine-EndLine" (for example: "lines=22-44"). Please see the example below
  • syntax (optional): Syntax will be inferred by fileType if not specified
  • header (optional): Will add header comment to code snippet. Useful for pointing to relative source directory or adding live doc links

Options are concatenated via the & sign. For example (CODE:src=readme.md&lines=10-20)

JSON to HTML table

Get JSON contents from an external file and convert it into an HTML table and insert's it in your markdown.

Options:

  • src: The relative path to the JSON file to pull in.

Github Workflow Artifacts table

Get the list of the latest artifacts generated from a workflow run. Generates a workflow artifacts table consists of artifacts download and workflow URL in an HTML table and inserts it in your markdown file.

Example Repo which uses all the markdown-autodocs feature

Local usage without Github action

Install markdown-autodocs CLI:

npm i -g markdown-autodocs

markdown-autodocs CLI usage:

dineshsonachalam@macbook ~ % markdown-autodocs --help
Usage: markdown-autodocs [options]

Options:
  -o, --outputFilePath <outputFilePaths...>  Output file paths
  -c, --category <categories...>             code-block, json-to-html-table, workflow-artifact-table
  -r, --repo <type>                          Repo name
  -b, --branch <type>                        Branch name
  -a, --accessToken <type>                   Github Access token
  -h, --help                                 display help for command
  • Code block
markdown-autodocs -c code-block -o ./README.md 
  • JSON to HTML table
markdown-autodocs -c json-to-html-table -o ./README.md
  • Github workflow artifacts table
markdown-autodocs -c workflow-artifact-table -o ./README.md -r $REPO -b $BRANCH -a $ACCESSTOKEN

Usage

Adding markdown-autodocs in your workflow

Add the following step at the end of your job, after other steps that might add or change files.

uses: dineshsonachalam/markdown-autodocs@v1.0.5

Extended example with all possible options available for this Action

- name: Markdown autodocs
- uses: dineshsonachalam/markdown-autodocs@v1.0.5
  with:
    # Optional, defaults to author of the commit that triggered the run
    commit_author: Author <actions@github.com>

    # Optional, defaults to "actions@github.com"
    commit_user_email: actions@github.com

    # Optional, but recommended
    # Defaults to "Apply automatic changes"
    commit_message: Apply automatic changes

    # Optional branch name where commit should be pushed to.
    # Defaults to the current branch.
    branch: feature-123

    # Optional output file paths, defaults to '[./README.md]'.
    output_file_paths: '[./README.md]'

    # Categories to automatically sync or transform its contents in the markdown files.
    # Defaults to '[code-block,json-to-html-table,workflow-artifact-table]'
    categories: '[code-block,json-to-html-table,workflow-artifact-table]'

Github Workflow Artifacts

ArtifactWorkflow
module-dependencies-license-reporttests
size-of-dependenciestests
vulnerabilities-audit-reporttests

Contributing

Used By


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
weareoutman/markdoc: An online markdown editor发布时间:2022-08-18
下一篇:
mattn/godown: Convert HTML into Markdown发布时间:2022-08-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap