Markdown automation made simple using markdown-autodocs github action
Tags: github, showdev, javascript, node
Published: 2021-06-28 01:29:05

---
title: Markdown automation made simple using markdown-autodocs github action
published: true
description: 
tags: #github #showdev #javascript #nodejs 
cover_image: https://camo.githubusercontent.com/3d9b4538dce6593853f940b6aa4c0b499cadf46225830582ee369a975436faec/68747470733a2f2f692e696d6775722e636f6d2f5a4143347150612e706e67
---

Hi everyone!, I just released markdown-autodocs GitHub action which will help you to auto-document your markdown files. Please give a star for this repo if you find it useful.

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

## Table of contents
- [Why markdown-autodocs?](#why-markdown-autodocs)
- [Features](#features)
- [Examples](#examples)
  - [CODE Block](#code-block)
  - [JSON to HTML table](#json-to-html-table)
  - [Github Workflow Artifacts table](#github-workflow-artifacts-table)
  - [Example Repo which uses all the markdown-autodocs feature](#example-repo-which-uses-all-the-markdown-autodocs-feature)
- [Usage](#usage)
  - [Adding markdown-autodocs in your workflow](#adding-markdown-autodocs-in-your-workflow)
  - [Extended example with all possible options available for this Action](#extended-example-with-all-possible-options-available-for-this-action)
- [Github Workflow Artifacts](#github-workflow-artifacts)
- [Contributing](#contributing)
- [License](#license)

## 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 <b>markdown-autodocs</b> 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
* <b>Code block:</b> Insert code snippet in your markdown file from external or remote files.
* <b>JSON to HTML table:</b> Insert HTML Table in your markdown file by converting JSON file contents to HTML table.
* <b>Github Workflow Artifacts table:</b> 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

<p align="center">Get code from external file</p>
<a href="https://gist.github.com/dineshsonachalam/f8eb73a29a379b3944fbfb0213c558bb#get-code-from-external-file" target="_blank">
    <img src="https://i.imgur.com/c8FskHr.png"/>
</a>


<p align="center">Get code from remote file</p>
<a href="https://gist.github.com/dineshsonachalam/f8eb73a29a379b3944fbfb0213c558bb#get-code-from-remote-file" target="_blank">
  <img src="https://i.imgur.com/kQ6qhlI.png"/>
</a>

### 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.

<a href="https://gist.github.com/dineshsonachalam/f8eb73a29a379b3944fbfb0213c558bb#json-to-html-table" target="_blank">
  <img src="https://i.imgur.com/t0pwMk2.png"/>
</a>

### 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.

<a href="https://gist.github.com/dineshsonachalam/f8eb73a29a379b3944fbfb0213c558bb#github-workflow-artifacts-table" target="_blank">
  <img src="https://i.imgur.com/Gr6P0bM.png"/>
</a>

### [Example Repo which uses all the markdown-autodocs feature](https://github.com/dineshsonachalam/repo-using-markdown-autodocs)

## 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.
<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=./docs/latest-release.yml) -->
<!-- The below code snippet is automatically added from ./docs/latest-release.yml -->
```yml
uses: dineshsonachalam/markdown-autodocs@v1.0.2
```
<!-- MARKDOWN-AUTO-DOCS:END -->

###  Extended example with all possible options available for this Action
<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=./docs/markdown-autodocs.yml) -->
<!-- The below code snippet is automatically added from ./docs/markdown-autodocs.yml -->
```yml
- name: Markdown autodocs
- uses: dineshsonachalam/markdown-autodocs@v1.0.2
  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]'
```
<!-- MARKDOWN-AUTO-DOCS:END -->

## Github Workflow Artifacts

<!-- MARKDOWN-AUTO-DOCS:START (WORKFLOW_ARTIFACT_TABLE) -->
<table class="ARTIFACTS-TABLE"><thead><tr><th class="artifact-th">Artifact</th><th class="workflow-th">Workflow</th></tr></thead><tbody ><tr ><td class="artifact-td td_text"><a href=https://github.com/dineshsonachalam/markdown-autodocs/suites/3097026321/artifacts/70769320>Jest-integration-test-report</a></td><td class="workflow-td td_text"><a href=https://github.com/dineshsonachalam/markdown-autodocs/actions/runs/976582803>integration-tests</a></td></tr>
<tr ><td class="artifact-td td_text"><a href=https://github.com/dineshsonachalam/markdown-autodocs/suites/3097026321/artifacts/70769321>module-dependencies-license-report</a></td><td class="workflow-td td_text"><a href=https://github.com/dineshsonachalam/markdown-autodocs/actions/runs/976582803>integration-tests</a></td></tr>
<tr ><td class="artifact-td td_text"><a href=https://github.com/dineshsonachalam/markdown-autodocs/suites/3097026321/artifacts/70769322>size-of-dependencies</a></td><td class="workflow-td td_text"><a href=https://github.com/dineshsonachalam/markdown-autodocs/actions/runs/976582803>integration-tests</a></td></tr>
<tr ><td class="artifact-td td_text"><a href=https://github.com/dineshsonachalam/markdown-autodocs/suites/3097026321/artifacts/70769323>vulnerabilities-audit-report</a></td><td class="workflow-td td_text"><a href=https://github.com/dineshsonachalam/markdown-autodocs/actions/runs/976582803>integration-tests</a></td></tr></tbody></table>
<!-- MARKDOWN-AUTO-DOCS:END -->

## Contributing


* [Code of Conduct](CODE_OF_CONDUCT.md)
* [Contributing Guideline](CONTRIBUTING.md)


## License

[MIT](https://choosealicense.com/licenses/mit/) © [dineshsonachalam](https://www.github.com/dineshsonachalam)