Skip to content

Commit

Permalink
Make TOC munge include blank line before TOC
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed Jul 17, 2015
1 parent 816f18a commit 6e4ec38
Show file tree
Hide file tree
Showing 31 changed files with 38 additions and 9 deletions.
1 change: 1 addition & 0 deletions cmd/mungedocs/toc.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func updateTOC(filePath string, markdown []byte) ([]byte, error) {
// builds the ToC.
func buildTOC(markdown []byte) ([]byte, error) {
var buffer bytes.Buffer
buffer.WriteString("\n")
scanner := bufio.NewScanner(bytes.NewReader(markdown))
inBlockQuotes := false
for scanner.Scan() {
Expand Down
12 changes: 6 additions & 6 deletions cmd/mungedocs/toc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ func Test_buildTOC(t *testing.T) {
in string
out string
}{
{"", ""},
{"Lorem ipsum\ndolor sit amet\n", ""},
{"", "\n"},
{"Lorem ipsum\ndolor sit amet\n", "\n"},
{
"# Title\nLorem ipsum \n## Section Heading\ndolor sit amet\n",
"- [Title](#title)\n - [Section Heading](#section-heading)\n",
"\n- [Title](#title)\n - [Section Heading](#section-heading)\n",
},
{
"# Title\nLorem ipsum \n## Section Heading\ndolor sit amet\n```bash\n#!/bin/sh\n```",
"- [Title](#title)\n - [Section Heading](#section-heading)\n",
"\n- [Title](#title)\n - [Section Heading](#section-heading)\n",
},
{
"# Title\nLorem ipsum \n## Section Heading\n### Ok, why doesn't this work? ...add 4 *more* `symbols`!\ndolor sit amet\n",
"- [Title](#title)\n - [Section Heading](#section-heading)\n - [Ok, why doesn't this work? ...add 4 *more* `symbols`!](#ok-why-doesnt-this-work-add-4-more-symbols)\n",
"\n- [Title](#title)\n - [Section Heading](#section-heading)\n - [Ok, why doesn't this work? ...add 4 *more* `symbols`!](#ok-why-doesnt-this-work-add-4-more-symbols)\n",
},
}
for _, c := range cases {
Expand All @@ -63,7 +63,7 @@ func Test_updateTOC(t *testing.T) {
},
{
"# Title\nLorem ipsum \n**table of contents**\n<!-- BEGIN MUNGE: GENERATED_TOC -->\nold cruft\n<!-- END MUNGE: GENERATED_TOC -->\n## Section Heading\ndolor sit amet\n",
"# Title\nLorem ipsum \n**table of contents**\n<!-- BEGIN MUNGE: GENERATED_TOC -->\n- [Title](#title)\n - [Section Heading](#section-heading)\n\n<!-- END MUNGE: GENERATED_TOC -->\n## Section Heading\ndolor sit amet\n",
"# Title\nLorem ipsum \n**table of contents**\n<!-- BEGIN MUNGE: GENERATED_TOC -->\n\n- [Title](#title)\n - [Section Heading](#section-heading)\n\n<!-- END MUNGE: GENERATED_TOC -->\n## Section Heading\ndolor sit amet\n",
},
}
for _, c := range cases {
Expand Down
1 change: 1 addition & 0 deletions docs/admin/admission-controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Admission Controllers](#admission-controllers)
- [What are they?](#what-are-they)
- [Why do I need them?](#why-do-i-need-them)
Expand Down
6 changes: 3 additions & 3 deletions docs/admin/cluster-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ Example addons are:
* [DNS](../../cluster/addons/dns/) provides cluster local DNS.
* [kube-ui](../../cluster/addons/kube-ui/) provides a graphical UI for the
cluster.
* [fluentd-elasticsearch](../../cluster/addons/fluentd-elasticsearch) provides
log storage. Also see the [gcp version](../../cluster/addons/fluentd-gcp).
* [cluster-monitoring](../../cluster/addons/cluster-monitoring) provides
* [fluentd-elasticsearch](../../cluster/addons/fluentd-elasticsearch/) provides
log storage. Also see the [gcp version](../../cluster/addons/fluentd-gcp/).
* [cluster-monitoring](../../cluster/addons/cluster-monitoring/) provides
monitoring for the cluster.

## Node components
Expand Down
1 change: 1 addition & 0 deletions docs/admin/high-availability.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [High Availability Kubernetes Clusters](#high-availability-kubernetes-clusters)
- [Introduction](#introduction)
- [Overview](#overview)
Expand Down
1 change: 1 addition & 0 deletions docs/admin/networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Networking in Kubernetes](#networking-in-kubernetes)
- [Summary](#summary)
- [Docker model](#docker-model)
Expand Down
1 change: 1 addition & 0 deletions docs/admin/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Node](#node)
- [What is a node?](#what-is-a-node)
- [Node Status](#node-status)
Expand Down
1 change: 1 addition & 0 deletions docs/devel/api-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ using resources with kubectl can be found in (working_with_resources.md).*

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Types (Kinds)](#types-kinds)
- [Resources](#resources)
- [Objects](#objects)
Expand Down
1 change: 1 addition & 0 deletions docs/getting-started-guides/scratch.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ steps that existing cluster setup scripts are making.
**Table of Contents**

<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Designing and Preparing](#designing-and-preparing)
- [Learning](#learning)
- [Cloud Provider](#cloud-provider)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Kubernetes User Guide: Managing Applications](#kubernetes-user-guide-managing-applications)
- [Quick walkthrough](#quick-walkthrough)
- [Thorough walkthrough](#thorough-walkthrough)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/accessing-the-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [User Guide to Accessing the Cluster](#user-guide-to-accessing-the-cluster)
- [Accessing the cluster API](#accessing-the-cluster-api)
- [Accessing for the first time with kubectl](#accessing-for-the-first-time-with-kubectl)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/application-troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ This is *not* a guide for people who want to debug their cluster. For that you

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Application Troubleshooting](#application-troubleshooting)
- [FAQ](#faq)
- [Diagnosing the problem](#diagnosing-the-problem)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/compute-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

** Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Compute Resources](#compute-resources)
- [Container and Pod Resource Limits](#container-and-pod-resource-limits)
- [How Pods with Resource Limits are Scheduled](#how-pods-with-resource-limits-are-scheduled)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/configuring-containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Kubernetes User Guide: Managing Applications: Configuring and launching containers](#kubernetes-user-guide-managing-applications-configuring-and-launching-containers)
- [Configuration in Kubernetes](#configuration-in-kubernetes)
- [Launching a container using a configuration file](#launching-a-container-using-a-configuration-file)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/connecting-applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Kubernetes User Guide: Managing Applications: Connecting applications](#kubernetes-user-guide-managing-applications-connecting-applications)
- [The Kubernetes model for connecting containers](#the-kubernetes-model-for-connecting-containers)
- [Exposing pods to the cluster](#exposing-pods-to-the-cluster)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/container-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Kubernetes Container Environment](#kubernetes-container-environment)
- [Overview](#overview)
- [Cluster Information](#cluster-information)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/debugging-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This document will hopefully help you to figure out what's going wrong.

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [My Service is not working - how to debug](#my-service-is-not-working---how-to-debug)
- [Conventions](#conventions)
- [Running commands in a Pod](#running-commands-in-a-pod)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/deploying-applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Kubernetes User Guide: Managing Applications: Deploying continuously running applications](#kubernetes-user-guide-managing-applications-deploying-continuously-running-applications)
- [Launching a set of replicas using a configuration file](#launching-a-set-of-replicas-using-a-configuration-file)
- [Viewing replication controller status](#viewing-replication-controller-status)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/docker-cli-to-kubectl.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ In this doc, we introduce the kubernetes command line to for interacting with th

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [kubectl for docker users](#kubectl-for-docker-users)
- [docker run](#docker-run)
- [docker ps](#docker-ps)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The `image` property of a container supports the same syntax as the `docker` com

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Images](#images)
- [Updating Images](#updating-images)
- [Using a Private Registry](#using-a-private-registry)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/introspection-and-debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ your pods. But there are a number of ways to get even more information about you

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Kubernetes User Guide: Managing Applications: Application Introspection and Debugging](#kubernetes-user-guide-managing-applications-application-introspection-and-debugging)
- [Using ```kubectl describe pod``` to fetch details about pods](#using-kubectl-describe-pod-to-fetch-details-about-pods)
- [Example: debugging Pending Pods](#example-debugging-pending-pods)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/managing-deployments.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ You’ve deployed your application and exposed it via a service. Now what? Kuber

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Kubernetes User Guide: Managing Applications: Managing deployments](#kubernetes-user-guide-managing-applications-managing-deployments)
- [Organizing resource configurations](#organizing-resource-configurations)
- [Bulk operations in kubectl](#bulk-operations-in-kubectl)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/persistent-volumes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ This document describes the current state of `PersistentVolumes` in Kubernetes.

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Persistent Volumes and Claims](#persistent-volumes-and-claims)
- [Introduction](#introduction)
- [Lifecycle of a volume and claim](#lifecycle-of-a-volume-and-claim)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/production-pods.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Kubernetes User Guide: Managing Applications: Working with pods and containers in production](#kubernetes-user-guide-managing-applications-working-with-pods-and-containers-in-production)
- [Persistent storage](#persistent-storage)
- [Distributing credentials](#distributing-credentials)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Kubernetes User Guide: Managing Applications: Quick start](#kubernetes-user-guide-managing-applications-quick-start)
- [Launching a simple application](#launching-a-simple-application)
- [Exposing your application to the Internet](#exposing-your-application-to-the-internet)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/replication-controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Replication Controller](#replication-controller)
- [What is a _replication controller_?](#what-is-a-replication-controller)
- [How does a replication controller work?](#how-does-a-replication-controller-work)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/secrets.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ a docker image. See [Secrets design document](../design/secrets.md) for more inf

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Secrets](#secrets)
- [Overview of Secrets](#overview-of-secrets)
- [Service Accounts Automatically Create and Use Secrets with API Credentials](#service-accounts-automatically-create-and-use-secrets-with-api-credentials)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Documentation for other releases can be found at

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Services in Kubernetes](#services-in-kubernetes)
- [Overview](#overview)
- [Defining a service](#defining-a-service)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/volumes.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Familiarity with [pods](pods.md) is suggested.

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Volumes](#volumes)
- [Background](#background)
- [Types of Volumes](#types-of-volumes)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/walkthrough/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ In order for the kubectl usage examples to work, make sure you have an examples

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Kubernetes 101 - Kubectl CLI and Pods](#kubernetes-101---kubectl-cli-and-pods)
- [Kubectl CLI](#kubectl-cli)
- [Pods](#pods)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/walkthrough/k8s201.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ In order for the kubectl usage examples to work, make sure you have an examples

**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->

- [Kubernetes 201 - Labels, Replication Controllers, Services and Health Checking](#kubernetes-201---labels-replication-controllers-services-and-health-checking)
- [Labels](#labels)
- [Replication Controllers](#replication-controllers)
Expand Down

0 comments on commit 6e4ec38

Please sign in to comment.