All Projects → technote-space → Toc Generator

technote-space / Toc Generator

Licence: mit
GitHub Actions to generate TOC (Table of Contents)

Programming Languages

typescript
32286 projects

Labels

Projects that are alternatives of or similar to Toc Generator

grav-plugin-toc
This plugin automagically generates a (minified) Table of Contents based on special markers in the document and adds it into the resulting HTML document.
Stars: ✭ 12 (-90%)
Mutual labels:  toc
Markdown Preview Enhanced
One of the 'BEST' markdown preview extensions for Atom editor!
Stars: ✭ 3,478 (+2798.33%)
Mutual labels:  toc
Tocbot
Build a table of contents from headings in an HTML document.
Stars: ✭ 862 (+618.33%)
Mutual labels:  toc
vue-showdowns-editor
A markdown editor using codemirror and previewer using @jhuix/showdowns for Vue.js.
Stars: ✭ 27 (-77.5%)
Mutual labels:  toc
angular-progress-bar
This component allow you to easy incorporate progress-bar to angular/ionic project, providing binding and color options
Stars: ✭ 26 (-78.33%)
Mutual labels:  toc
Github Markdown Toc.go
Easy TOC creation for GitHub README.md (in go)
Stars: ✭ 387 (+222.5%)
Mutual labels:  toc
tocer
A command line interface for generating table of contents for Markdown files.
Stars: ✭ 44 (-63.33%)
Mutual labels:  toc
Norepeat
The norepeat package contains some magical function, tools
Stars: ✭ 111 (-7.5%)
Mutual labels:  toc
JekyllTheme-ProjectGaia
Jekyll Theme Project Gaia. V2 Beta Released !! Check it out ->
Stars: ✭ 110 (-8.33%)
Mutual labels:  toc
Runoob Pdf
爬取菜鸟教程网站并转PDF__python_crawer_by_chrome
Stars: ✭ 430 (+258.33%)
Mutual labels:  toc
markdown-index
Generate a global index for multiple markdown files recursively
Stars: ✭ 15 (-87.5%)
Mutual labels:  toc
PointingToTheMoon
Super slim Jekyll Theme created for math posts with easy mermaid diagram
Stars: ✭ 49 (-59.17%)
Mutual labels:  toc
Contents
Table of contents generator.
Stars: ✭ 404 (+236.67%)
Mutual labels:  toc
tocdown
A table of contents generator for markdown
Stars: ✭ 11 (-90.83%)
Mutual labels:  toc
Markdown Toc
Generate a markdown TOC (table of contents) for a README or any markdown files, using remarkable. Used by assemble, verb, and lots of other projects on GitHub. API and CLI.
Stars: ✭ 1,185 (+887.5%)
Mutual labels:  toc
gitbook-plugin-atoc
A TOC plugin for GitBook
Stars: ✭ 22 (-81.67%)
Mutual labels:  toc
Jekyll Toc
A GitHub Pages compatible Table of Contents generator without a plugin or JavaScript
Stars: ✭ 306 (+155%)
Mutual labels:  toc
Jekylltheme Projectgaia
Jekyll Theme Project Gaia. V2 Beta Released !! Check it out ->
Stars: ✭ 111 (-7.5%)
Mutual labels:  toc
Hexo Toc
📖 Insert a markdown TOC before posts be rendered.
Stars: ✭ 106 (-11.67%)
Mutual labels:  toc
Vim Markdown Toc
A vim 7.4+ plugin to generate table of contents for Markdown files.
Stars: ✭ 427 (+255.83%)
Mutual labels:  toc

TOC Generator

CI Status codecov CodeFactor License: MIT

Read this in other languages: English, 日本語.

This is a GitHub Actions to generate TOC (Table of Contents),
which executes DocToc and commits if changed.

Table of Contents

Details

Installation

  1. Specify location of TOC (option)
    e.g. README.md
    <!-- START doctoc -->
    <!-- END doctoc -->
    
    detail
  2. Setup workflow
    e.g. .github/workflows/toc.yml
    on: push
    name: TOC Generator
    jobs:
      generateTOC:
        name: TOC Generator
        runs-on: ubuntu-latest
        steps:
          - uses: technote-space/[email protected]
    

Screenshot

behavior

Options

name description default required e.g.
TARGET_PATHS Target file path. (Comma separated, Detail) README*.md true README*.md,CHANGELOG.md, .
TOC_TITLE TOC Title **Table of Contents** ''
MAX_HEADER_LEVEL Maximum heading level. (Detail) 3
CUSTOM_MODE Whether it is custom mode(Generated Example) false true
CUSTOM_TEMPLATE Custom template for custom mode <p align="center">${ITEMS}</p>
ITEM_TEMPLATE Item template for custom mode <a href="${LINK}">${TEXT}</a>
SEPARATOR Separator for custom mode <span>|</span>
FOLDING Whether to make TOC foldable false true
COMMIT_MESSAGE Commit message chore(docs): update TOC true docs: update TOC
COMMIT_NAME Git commit name ${github.actor}
COMMIT_EMAIL Git commit email ${github.actor}@users.noreply.github.com
CREATE_PR Whether to create PullRequest false true
CHECK_ONLY_DEFAULT_BRANCH Whether to check only default branch false true
PR_BRANCH_PREFIX PullRequest branch prefix toc-generator/ true
PR_BRANCH_NAME PullRequest branch name
Context variables
update-toc-${PR_ID} true toc-${PR_NUMBER}
PR_TITLE PullRequest title
Context variables
chore(docs): update TOC (${PR_MERGE_REF}) true docs: update TOC
PR_BODY PullRequest body
Context PR variables
action.yml true
PR_COMMENT_BODY PullRequest body for comment
Context PR variables
action.yml
PR_CLOSE_MESSAGE Message body when closing PullRequest This PR has been closed because it is no longer needed.
TARGET_BRANCH_PREFIX Filter by branch name release/
INCLUDE_LABELS Labels used to check if the PullRequest has it Label1, Label2
OPENING_COMMENT Opening comment (for other than DocToc) <!-- toc
CLOSING_COMMENT Closing comment (for other than DocToc) <!-- tocstop
GITHUB_TOKEN Access token ${{github.token}} true ${{secrets.ACCESS_TOKEN}}

Specify options individually

The options used for doctoc can be commented to specify values.
If you want to generate multiple TOCs with different settings, specify the values individually as follows.

e.g.

<!-- START doctoc -->
<!-- param::isNotitle::true:: -->
<!-- param::isCustomMode::true:: -->

<!-- END doctoc -->

...

Action event details

Target event

eventName: action condition
push: * condition1
pull_request: [opened, synchronize, reopened, labeled, unlabeled] condition2
pull_request: [closed]
schedule, repository_dispatch, workflow_dispatch
  • The following activity types must be explicitly specified (detail)
    • labeled, unlabeled, closed

Conditions

condition1

condition2

Addition

GITHUB_TOKEN

The GITHUB_TOKEN that is provided as a part of GitHub Actions doesn't have authorization to create any successive events.
So it won't spawn actions which triggered by push.

This can be a problem if you have branch protection configured.

If you want to trigger actions, use a personal access token instead.

  1. Generate a personal access token with the public_repo or repo scope.
    (repo is required for private repositories).
  2. Save as ACCESS_TOKEN
  3. Add input to use ACCESS_TOKEN instead of GITHUB_TOKEN.
    e.g. .github/workflows/toc.yml
    on: push
    name: TOC Generator
    jobs:
      generateTOC:
        name: TOC Generator
        runs-on: ubuntu-latest
        steps:
          - uses: technote-space/[email protected]
            with:
              GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
    

Create PullRequest

If CREATE_PR is set to true, a PullRequest is created.

on: pull_request
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/[email protected]
        with:
          CREATE_PR: true

create pr

If the closed activity type is set, this action closes the PR when it is no longer needed.

on:
  pull_request:
    types: [opened, synchronize, reopened, closed]
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/[email protected]

Context variables

name description
PR_NUMBER pull_request.number (e.g. 11)
PR_NUMBER_REF #${pull_request.number} (e.g. #11)
PR_ID pull_request.id (e.g. 21031067)
PR_HEAD_REF pull_request.head.ref (e.g. change)
PR_BASE_REF pull_request.base.ref (e.g. master)
PR_MERGE_REF pull_request.base.ref (e.g. change -> master)
PR_TITLE pull_request.title (e.g. update the README with new information.)

Payload example

Context PR variables

name description
PR_LINK Link to PR
COMMANDS_OUTPUT Result of TOC command
FILES_SUMMARY e.g. Changed 2 files
FILES Changed file list

Configuration Examples

Example 1

Execute actions at push without limiting the branch and commit directly

on: push
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/[email protected]

Example 2

Create or update a Pull Request by executing actions on a Pull Request update only for branches starting with release/.

on:
  pull_request:
    types: [opened, synchronize, reopened, closed]
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/[email protected]
        with:
          CREATE_PR: true
          TARGET_BRANCH_PREFIX: release/

Example 3

Execute actions in the schedule for the default branch only and commit directly.
(Using the Token created for the launch of other workflows)

on:
  schedule:
    - cron: "0 23 * * *"
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/[email protected]
        with:
          GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
          CHECK_ONLY_DEFAULT_BRANCH: true

Sample repositories using this Action

Author

GitHub (Technote)
Blog

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].