-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from solana-developers/re-add-function-params
refactor: use task based headings, re-add usage, add tool to generate links
- Loading branch information
Showing
3 changed files
with
131 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// A quick tool to generate the table of contents in the README | ||
// Usage: 'esrun make-table-of-contents.ts' | ||
|
||
import { exec as oldExec } from "node:child_process"; | ||
import { promisify } from "node:util"; | ||
const exec = promisify(oldExec); | ||
const log = console.log.bind(console); | ||
|
||
// Get all the headings from the README | ||
const command = `git grep -h '^### ' README.md`; | ||
const { stdout } = await exec(command); | ||
|
||
const headings = stdout.split("\n"); | ||
|
||
const headingToLink = (markdownHeading: string) => { | ||
// A markdown heading like: | ||
// ### Get the logs for a transaction | ||
// becomes a link like: | ||
// #get-the-logs-for-a-transaction | ||
|
||
const heading = markdownHeading.slice(4); | ||
|
||
// replace all the spaces with a dash | ||
// and remove any commas | ||
const link = heading.toLowerCase().replaceAll(/ /g, "-").replaceAll(/,/g, ""); | ||
|
||
return `[${heading}](#${link})`; | ||
}; | ||
|
||
const links = headings.map((heading) => { | ||
return headingToLink(heading); | ||
}); | ||
|
||
log(links.join("\n\n")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters