Skip to content

Commit 4d678ce

Browse files
authored
Fix links on chezmoi.io (#493)
Fix links on chezmoi.io
2 parents a362775 + 05bd6e2 commit 4d678ce

File tree

10 files changed

+55
-42
lines changed

10 files changed

+55
-42
lines changed

chezmoi.io/Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ content-docs: \
1212
content/docs/quick-start.md \
1313
content/docs/reference.md
1414

15-
content/docs/changes.md: ../docs/CHANGES.md Makefile
15+
content/docs/changes.md: ../docs/CHANGES.md ../internal/generate-chezmoi.io-content-docs/main.go Makefile
1616
go run ../internal/generate-chezmoi.io-content-docs -shorttitle="Changes" -longtitle="Changes" < $< > $@ || ( rm -f $@ ; false )
1717

18-
content/docs/contributing.md: ../docs/CONTRIBUTING.md Makefile
18+
content/docs/contributing.md: ../docs/CONTRIBUTING.md ../internal/generate-chezmoi.io-content-docs/main.go Makefile
1919
go run ../internal/generate-chezmoi.io-content-docs -shorttitle="Contributing" -longtitle="Contributing Guide" < $< > $@ || ( rm -f $@ ; false )
2020

21-
content/docs/faq.md: ../docs/FAQ.md Makefile
21+
content/docs/faq.md: ../docs/FAQ.md ../internal/generate-chezmoi.io-content-docs/main.go Makefile
2222
go run ../internal/generate-chezmoi.io-content-docs -shorttitle="FAQ" -longtitle="Frequently Asked Questions" < $< > $@ || ( rm -f $@ ; false )
2323

24-
content/docs/how-to.md: ../docs/HOWTO.md Makefile
24+
content/docs/how-to.md: ../docs/HOWTO.md ../internal/generate-chezmoi.io-content-docs/main.go Makefile
2525
go run ../internal/generate-chezmoi.io-content-docs -shorttitle="How-To" -longtitle="How-To Guide" < $< > $@ || ( rm -f $@ ; false )
2626

27-
content/docs/install.md: ../docs/INSTALL.md Makefile
27+
content/docs/install.md: ../docs/INSTALL.md ../internal/generate-chezmoi.io-content-docs/main.go Makefile
2828
go run ../internal/generate-chezmoi.io-content-docs -shorttitle="Install" -longtitle="Install Guide" < $< > $@ || ( rm -f $@ ; false )
2929

30-
content/docs/quick-start.md: ../docs/QUICKSTART.md Makefile
30+
content/docs/quick-start.md: ../docs/QUICKSTART.md ../internal/generate-chezmoi.io-content-docs/main.go Makefile
3131
go run ../internal/generate-chezmoi.io-content-docs -shorttitle="Quick Start" -longtitle="Quick Start Guide" < $< > $@ || ( rm -f $@ ; false )
3232

33-
content/docs/reference.md: ../docs/REFERENCE.md Makefile
33+
content/docs/reference.md: ../docs/REFERENCE.md ../internal/generate-chezmoi.io-content-docs/main.go Makefile
3434
go run ../internal/generate-chezmoi.io-content-docs -shorttitle="Reference" -longtitle="Reference Manual" < $< > $@ || ( rm -f $@ ; false )
3535

chezmoi.io/content/_index.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ type: docs
77

88
Manage your dotfiles across multiple machines, securely.
99

10-
* [What does chezmoi do and why should I use it?](#what-does-chezmoi-do-and-why-should-i-use-it)
11-
* [What are chezmoi's key features?](#what-are-chezmois-key-features)
12-
* [I already have a system to manage my dotfiles, why should I use chezmoi?](#i-already-have-a-system-to-manage-my-dotfiles-why-should-i-use-chezmoi)
13-
* [How do I start with chezmoi?](#how-do-i-start-with-chezmoi)
14-
* [License](#license)
15-
1610
## What does chezmoi do and why should I use it?
1711

1812
chezmoi helps you manage your personal configuration files (dotfiles) across

docs/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# chezmoi Changes
22

3+
<!--- toc --->
34
* [Upcoming](#upcoming)
45
* [`gpgRecipient` config variable changing to `gpg.recipient`](#gpgrecipient-config-variable-changing-to-gpgrecipient)
56

docs/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# chezmoi Contributing Guide
22

3+
<!--- toc --->
34
* [Getting started](#getting-started)
45
* [Developing locally](#developing-locally)
56
* [Contributing changes](#contributing-changes)

docs/FAQ.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# chezmoi Frequently Asked Questions
22

3+
<!--- toc --->
34
* [How can I quickly check for problems with chezmoi on my machine?](#how-can-i-quickly-check-for-problems-with-chezmoi-on-my-machine)
45
* [What are the consequences of "bare" modifications to the target files? If my `.zshrc` is managed by chezmoi and I edit `~/.zshrc` without using `chezmoi edit`, what happens?](#what-are-the-consequences-of-bare-modifications-to-the-target-files-if-my-zshrc-is-managed-by-chezmoi-and-i-edit-zshrc-without-using-chezmoi-edit-what-happens)
56
* [How can I tell what dotfiles in my home directory aren't managed by chezmoi? Is there an easy way to have chezmoi manage a subset of them?](#how-can-i-tell-what-dotfiles-in-my-home-directory-arent-managed-by-chezmoi-is-there-an-easy-way-to-have-chezmoi-manage-a-subset-of-them)

docs/HOWTO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# chezmoi How-To Guide
22

3+
<!--- toc --->
34
* [Use a hosted repo to manage your dotfiles across multiple machines](#use-a-hosted-repo-to-manage-your-dotfiles-across-multiple-machines)
45
* [Pull the latest changes from your repo and apply them](#pull-the-latest-changes-from-your-repo-and-apply-them)
56
* [Pull the latest changes from your repo and see what would change, without actually applying the changes](#pull-the-latest-changes-from-your-repo-and-see-what-would-change-without-actually-applying-the-changes)

docs/INSTALL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# chezmoi Install Guide
22

3+
<!--- toc --->
34
* [One-line binary install](#one-line-binary-install)
45
* [One-line package install](#one-line-package-install)
56
* [Pre-built Linux packages](#pre-built-linux-packages)

docs/QUICKSTART.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# chezmoi Quick Start Guide
22

3+
<!--- toc --->
34
* [Concepts](#concepts)
45
* [Start using chezmoi on your current machine](#start-using-chezmoi-on-your-current-machine)
56
* [Using chezmoi across multiple machines](#using-chezmoi-across-multiple-machines)

docs/REFERENCE.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22

33
Manage your dotfiles securely across multiple machines.
44

5+
<!--- toc --->
56
* [Concepts](#concepts)
67
* [Global command line flags](#global-command-line-flags)
7-
* [`--color` *value*](#color-value)
8-
* [`-c`, `--config` *filename*](#c---config-filename)
9-
* [`--debug`](#debug)
10-
* [`-D`, `--destination` *directory*](#d---destination-directory)
11-
* [`-f`, `--follow`](#f---follow)
12-
* [`-n`, `--dry-run`](#n---dry-run)
13-
* [`-h`, `--help`](#h---help)
14-
* [`-r`. `--remove`](#r---remove)
15-
* [`-S`, `--source` *directory*](#s---source-directory)
16-
* [`-v`, `--verbose`](#v---verbose)
17-
* [`--version`](#version)
8+
* [`--color` *value*](#--color-value)
9+
* [`-c`, `--config` *filename*](#-c---config-filename)
10+
* [`--debug`](#--debug)
11+
* [`-D`, `--destination` *directory*](#-d---destination-directory)
12+
* [`-f`, `--follow`](#-f---follow)
13+
* [`-n`, `--dry-run`](#-n---dry-run)
14+
* [`-h`, `--help`](#-h---help)
15+
* [`-r`. `--remove`](#-r---remove)
16+
* [`-S`, `--source` *directory*](#-s---source-directory)
17+
* [`-v`, `--verbose`](#-v---verbose)
18+
* [`--version`](#--version)
1819
* [Configuration file](#configuration-file)
1920
* [Configuration variables](#configuration-variables)
2021
* [Source state attributes](#source-state-attributes)

internal/generate-chezmoi.io-content-docs/main.go

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,53 @@
11
package main
22

33
import (
4-
"bytes"
4+
"bufio"
55
"flag"
66
"fmt"
7-
"io/ioutil"
7+
"log"
88
"os"
99
)
1010

1111
var (
12+
debug = flag.Bool("debug", false, "debug")
1213
shortTitle = flag.String("shorttitle", "", "short title")
1314
longTitle = flag.String("longtitle", "", "long title")
1415
)
1516

1617
func run() error {
1718
flag.Parse()
1819

19-
data, err := ioutil.ReadAll(os.Stdin)
20-
if err != nil {
21-
return err
22-
}
23-
24-
fmt.Printf(
25-
"+++\n"+
26-
"title = %q\n"+
27-
"+++\n"+
28-
"\n"+
29-
"# %s\n",
20+
fmt.Printf(""+
21+
"---\n"+
22+
"title: %q\n"+
23+
"---\n"+
24+
"\n",
3025
*shortTitle,
31-
*longTitle,
3226
)
3327

34-
if index := bytes.IndexByte(data, '\n'); index != -1 {
35-
os.Stdout.Write(data[index+1:])
28+
s := bufio.NewScanner(os.Stdin)
29+
state := "replace-title"
30+
for s.Scan() {
31+
if *debug {
32+
log.Printf("%s: %q", state, s.Text())
33+
}
34+
switch state {
35+
case "replace-title":
36+
fmt.Printf("# %s\n\n", *longTitle)
37+
state = "find-toc"
38+
case "find-toc":
39+
if s.Text() == "<!--- toc --->" {
40+
state = "skip-toc"
41+
}
42+
case "skip-toc":
43+
if s.Text() == "" {
44+
state = "copy-content"
45+
}
46+
case "copy-content":
47+
fmt.Println(s.Text())
48+
}
3649
}
37-
38-
return nil
50+
return s.Err()
3951
}
4052

4153
func main() {

0 commit comments

Comments
 (0)