Skip to content

Commit

Permalink
docs(readme): add module usage
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Sep 9, 2023
1 parent 1712d94 commit 90b6e90
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"description": "Generate a table of contents for a GitHub discussion",
"author": "Gregor Martynus (https://github.com/gr2m)",
"license": "ISC",
"repository": "github:gr2m/github-discussion-toc",
"dependencies": {
"octokit": "^3.1.0"
},
Expand Down
18 changes: 17 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,30 @@ A script to generate a table of contents for a GitHub discussion.

The script finds all comments that begin with a level 3 heading (`### My heading`) and adds a table of contents with links to those headings to the top of the discussion.

## Usage
## CLI Usage

You need a [GitHub personal access token](https://github.com/settings/tokens/new?scopes=public_repo&description=github-discussion-toc) with the `public_repo` scope for public repositories or the `repo` scope for private repositories.

```
GITHUB_TOKEN="<personal access token>" npx github-discussion-toc <discussion-url>
```

## Module usage

```js
import addTocToGitHubDiscussion from "github-discussion-toc";
import { Octokit } from "octokit";

const myOctokit = new Octokit({
auth: process.env.GITHUB_TOKEN,
});
const myOwner = "octocat";
const myRepo = "hello-world";
const myDiscussionNumber = 123;

await addTocToGitHubDiscussion(myOctokit, myOwner, myRepo, myDiscussionNumber);
```

## License

[ISC](license.md)

0 comments on commit 90b6e90

Please sign in to comment.