Skip to content

Commit

Permalink
link to the source of each command in the doc (#166)
Browse files Browse the repository at this point in the history
the _real_ changes happen in `toolkit.nu` and around the
`nu-git-manager-sugar git prompt setup` command.
the rest is just regenerating the documentation with `toolkit doc`.
  • Loading branch information
amtoine authored Jan 25, 2024
1 parent 1f4153d commit 60f6b86
Show file tree
Hide file tree
Showing 29 changed files with 55 additions and 29 deletions.
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/extra/gm-report.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm report` (`nu-git-manager-sugar extra`)
# `gm report` from `nu-git-manager-sugar extra` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/extra.nu#L23))
get a full report about the local store of repositories

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-bisect.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo bisect` (`nu-git-manager-sugar git`)
# `gm repo bisect` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L380))
bisect a worktree by running a piece of code repeatedly

# Examples
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo branch interactive-delete` (`nu-git-manager-sugar git`)
# `gm repo branch interactive-delete` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L226))
remove a branch interactively


Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-branch-wipe.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo branch wipe` (`nu-git-manager-sugar git`)
# `gm repo branch wipe` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L113))
wipe a branch completely, i.e. both locally and remotely


Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-branches.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo branches` (`nu-git-manager-sugar git`)
# `gm repo branches` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L72))
inspect local branches

> **Note**
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-compare.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo compare` (`nu-git-manager-sugar git`)
# `gm repo compare` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L31))
compare the changes between two revisions, from a target to the "head"


Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-fetch-branch.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo fetch branch` (`nu-git-manager-sugar git`)
# `gm repo fetch branch` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L174))
fetch a remote branch locally, without pulling down the whole remote


Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-get-commit.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo get commit` (`nu-git-manager-sugar git`)
# `gm repo get commit` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L24))
get the commit hash of any revision

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-goto-root.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo goto root` (`nu-git-manager-sugar git`)
# `gm repo goto root` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L52))
go to the root of the repository from anywhere in the worktree

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-is-ancestor.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo is-ancestor` (`nu-git-manager-sugar git`)
# `gm repo is-ancestor` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L140))
return true iif the first revision is an ancestor of the second

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-ls.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo ls` (`nu-git-manager-sugar git`)
# `gm repo ls` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L270))
get some information about a repo


Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-query.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo query` (`nu-git-manager-sugar git`)
# `gm repo query` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L320))
queries the `.git/` directory as a database with `nu_plugin_git_query`

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-remote-list.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo remote list` (`nu-git-manager-sugar git`)
# `gm repo remote list` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L159))
get the list of all the remotes in the current repository

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/gm-repo-switch.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm repo switch` (`nu-git-manager-sugar git`)
# `gm repo switch` from `nu-git-manager-sugar git` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu#L246))
switch between branches interactively


Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/git/prompt/setup.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `setup` (`nu-git-manager-sugar git prompt`)
# `setup` from `nu-git-manager-sugar git prompt` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/prompt.nu#L62))
setup the Git prompt of NGM

the different sections of the prompt are the following, in order and separated by a single space:
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/github/gm-gh-pr-checkout.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm gh pr checkout` (`nu-git-manager-sugar github`)
# `gm gh pr checkout` from `nu-git-manager-sugar github` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/github.nu#L211))
checkout one of the repo's PR interactively


Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/github/gm-gh-query-api.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm gh query-api` (`nu-git-manager-sugar github`)
# `gm gh query-api` from `nu-git-manager-sugar github` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/github.nu#L83))
query the GitHub API for any end point

> :bulb: **Note**
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/github/gm-gh-query-releases.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm gh query-releases` (`nu-git-manager-sugar github`)
# `gm gh query-releases` from `nu-git-manager-sugar github` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/github.nu#L188))
list the releases of a GitHub repository

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager-sugar/github/gm-gh-query-user.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm gh query-user` (`nu-git-manager-sugar github`)
# `gm gh query-user` from `nu-git-manager-sugar github` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/github.nu#L203))
get information about a GitHub user

## Examples:
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager/gm-clean.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm clean` (`nu-git-manager`)
# `gm clean` from `nu-git-manager` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager/nu-git-manager/mod.nu#L552))
clean the store

this command will mainly remove empty directory recursively.
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager/gm-clone.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm clone` (`nu-git-manager`)
# `gm clone` from `nu-git-manager` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager/nu-git-manager/mod.nu#L88))
clone a remote Git repository into your local store

will give a nice error if the repository is already in the local store.
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager/gm-list.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm list` (`nu-git-manager`)
# `gm list` from `nu-git-manager` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager/nu-git-manager/mod.nu#L216))
list all the local repositories in your local store

**/!\\** this command will return sanitized paths. **/!\\**
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager/gm-remove.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm remove` (`nu-git-manager`)
# `gm remove` from `nu-git-manager` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager/nu-git-manager/mod.nu#L354))
remove one of the repositories from your local store

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager/gm-squash-forks.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm squash-forks` (`nu-git-manager`)
# `gm squash-forks` from `nu-git-manager` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager/nu-git-manager/mod.nu#L475))
squash multi-directory forks into a single repo

Here, two forks are defined as *two non-grafted repositories that share the same initial commit,
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager/gm-status.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm status` (`nu-git-manager`)
# `gm status` from `nu-git-manager` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager/nu-git-manager/mod.nu#L284))
get current status about the repositories managed by NGM

**/!\\** `$.root.path` and `$.cache.path` will be sanitized **/!\\**
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager/gm-update-cache.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm update-cache` (`nu-git-manager`)
# `gm update-cache` from `nu-git-manager` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager/nu-git-manager/mod.nu#L317))
update the local cache of repositories

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/nu-git-manager/gm.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `gm` (`nu-git-manager`)
# `gm` from `nu-git-manager` (see [source](https://github.com/amtoine/nu-git-manager/blob/main/pkgs/nu-git-manager/nu-git-manager/mod.nu#L55))
manage your Git repositories with the main command of NGM

### the location for the store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const DEFAULT_PROMPT_INDICATORS = {
# }
# }
# ```
export def --env setup [
export def --env "setup" [
--indicators = $DEFAULT_PROMPT_INDICATORS,
--duration-threshold: duration = 1sec # the threshold above which the command duration is shown
]: nothing -> nothing {
Expand Down
28 changes: 27 additions & 1 deletion toolkit.nu
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@ def run-nu [code: string]: nothing -> any {
^$nu.current-exe --no-config-file --commands ($code ++ " | to nuon") | from nuon
}

def rg [root: path, pattern: string]: nothing -> table<file: path, line: int, match: string> {
ls ($root | path join "**" "*")
| where type == file
| get name
| wrap file
| insert match {|it|
open $it.file --raw
| lines
| enumerate
| rename line match
| update line { $in + 1 }
| find --regex $pattern
}
| where not ($it.match | is-empty)
| flatten --all
}

def document-command [
args: record<module_name: string, full_module_name_with_leading_path: string, root: path>
]: string -> string {
Expand All @@ -181,8 +198,17 @@ def document-command [

let signatures = $help.signatures | transpose | get column1

let res = rg $args.root $'export def.*"($command)"'
let res = match ($res | length) {
0 => { error make --unspanned { msg: $"no match for command `($command)`" } },
1 => { $res.0 | into record },
_ => { error make --unspanned { msg: $"too many matches for command `($command)`" } },
}

let source = $"https://github.com/amtoine/nu-git-manager/blob/main/($res.file | path relative-to $args.root)#L($res.line)"

let page = [
$"# `($command)` \(`($args.module_name)`\)",
$"# `($command)` from `($args.module_name)` \(see [source]\(($source)\)\)",
$help.usage,
"",
$help.extra_usage,
Expand Down

0 comments on commit 60f6b86

Please sign in to comment.