Skip to content

Commit

Permalink
Fix links on chezmoi.io (#493)
Browse files Browse the repository at this point in the history
Fix links on chezmoi.io
  • Loading branch information
twpayne committed Nov 23, 2019
2 parents a362775 + 05bd6e2 commit 4d678ce
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 42 deletions.
14 changes: 7 additions & 7 deletions chezmoi.io/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ content-docs: \
content/docs/quick-start.md \
content/docs/reference.md

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

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

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

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

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

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

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

6 changes: 0 additions & 6 deletions chezmoi.io/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ type: docs

Manage your dotfiles across multiple machines, securely.

* [What does chezmoi do and why should I use it?](#what-does-chezmoi-do-and-why-should-i-use-it)
* [What are chezmoi's key features?](#what-are-chezmois-key-features)
* [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)
* [How do I start with chezmoi?](#how-do-i-start-with-chezmoi)
* [License](#license)

## What does chezmoi do and why should I use it?

chezmoi helps you manage your personal configuration files (dotfiles) across
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# chezmoi Changes

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

Expand Down
1 change: 1 addition & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# chezmoi Contributing Guide

<!--- toc --->
* [Getting started](#getting-started)
* [Developing locally](#developing-locally)
* [Contributing changes](#contributing-changes)
Expand Down
1 change: 1 addition & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# chezmoi Frequently Asked Questions

<!--- toc --->
* [How can I quickly check for problems with chezmoi on my machine?](#how-can-i-quickly-check-for-problems-with-chezmoi-on-my-machine)
* [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)
* [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)
Expand Down
1 change: 1 addition & 0 deletions docs/HOWTO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# chezmoi How-To Guide

<!--- toc --->
* [Use a hosted repo to manage your dotfiles across multiple machines](#use-a-hosted-repo-to-manage-your-dotfiles-across-multiple-machines)
* [Pull the latest changes from your repo and apply them](#pull-the-latest-changes-from-your-repo-and-apply-them)
* [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)
Expand Down
1 change: 1 addition & 0 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# chezmoi Install Guide

<!--- toc --->
* [One-line binary install](#one-line-binary-install)
* [One-line package install](#one-line-package-install)
* [Pre-built Linux packages](#pre-built-linux-packages)
Expand Down
1 change: 1 addition & 0 deletions docs/QUICKSTART.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# chezmoi Quick Start Guide

<!--- toc --->
* [Concepts](#concepts)
* [Start using chezmoi on your current machine](#start-using-chezmoi-on-your-current-machine)
* [Using chezmoi across multiple machines](#using-chezmoi-across-multiple-machines)
Expand Down
23 changes: 12 additions & 11 deletions docs/REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

Manage your dotfiles securely across multiple machines.

<!--- toc --->
* [Concepts](#concepts)
* [Global command line flags](#global-command-line-flags)
* [`--color` *value*](#color-value)
* [`-c`, `--config` *filename*](#c---config-filename)
* [`--debug`](#debug)
* [`-D`, `--destination` *directory*](#d---destination-directory)
* [`-f`, `--follow`](#f---follow)
* [`-n`, `--dry-run`](#n---dry-run)
* [`-h`, `--help`](#h---help)
* [`-r`. `--remove`](#r---remove)
* [`-S`, `--source` *directory*](#s---source-directory)
* [`-v`, `--verbose`](#v---verbose)
* [`--version`](#version)
* [`--color` *value*](#--color-value)
* [`-c`, `--config` *filename*](#-c---config-filename)
* [`--debug`](#--debug)
* [`-D`, `--destination` *directory*](#-d---destination-directory)
* [`-f`, `--follow`](#-f---follow)
* [`-n`, `--dry-run`](#-n---dry-run)
* [`-h`, `--help`](#-h---help)
* [`-r`. `--remove`](#-r---remove)
* [`-S`, `--source` *directory*](#-s---source-directory)
* [`-v`, `--verbose`](#-v---verbose)
* [`--version`](#--version)
* [Configuration file](#configuration-file)
* [Configuration variables](#configuration-variables)
* [Source state attributes](#source-state-attributes)
Expand Down
48 changes: 30 additions & 18 deletions internal/generate-chezmoi.io-content-docs/main.go
Original file line number Diff line number Diff line change
@@ -1,41 +1,53 @@
package main

import (
"bytes"
"bufio"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
)

var (
debug = flag.Bool("debug", false, "debug")
shortTitle = flag.String("shorttitle", "", "short title")
longTitle = flag.String("longtitle", "", "long title")
)

func run() error {
flag.Parse()

data, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return err
}

fmt.Printf(
"+++\n"+
"title = %q\n"+
"+++\n"+
"\n"+
"# %s\n",
fmt.Printf(""+
"---\n"+
"title: %q\n"+
"---\n"+
"\n",
*shortTitle,
*longTitle,
)

if index := bytes.IndexByte(data, '\n'); index != -1 {
os.Stdout.Write(data[index+1:])
s := bufio.NewScanner(os.Stdin)
state := "replace-title"
for s.Scan() {
if *debug {
log.Printf("%s: %q", state, s.Text())
}
switch state {
case "replace-title":
fmt.Printf("# %s\n\n", *longTitle)
state = "find-toc"
case "find-toc":
if s.Text() == "<!--- toc --->" {
state = "skip-toc"
}
case "skip-toc":
if s.Text() == "" {
state = "copy-content"
}
case "copy-content":
fmt.Println(s.Text())
}
}

return nil
return s.Err()
}

func main() {
Expand Down

0 comments on commit 4d678ce

Please sign in to comment.