From ad8f8731b6fda414c21f263c541c27854d64d851 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Fri, 10 Jul 2015 21:50:56 -0700 Subject: [PATCH] Use a common set of tag prefixes for munges All munges now start with ` and , and replaces anything between those with +// Then, finds the magic macro block tags and replaces anything between those with // the ToC, thereby updating any previously inserted ToC. // // TODO(erictune): put this in own package with tests @@ -36,7 +38,7 @@ func updateTOC(filePath string, markdown []byte) ([]byte, error) { return nil, err } lines := splitLines(markdown) - updatedMarkdown, err := updateMacroBlock(lines, "", "", string(toc)) + updatedMarkdown, err := updateMacroBlock(lines, beginMungeTag(tocMungeTag), endMungeTag(tocMungeTag), string(toc)) if err != nil { return nil, err } diff --git a/cmd/mungedocs/toc_test.go b/cmd/mungedocs/toc_test.go index 5175d8089f1..4875d93c049 100644 --- a/cmd/mungedocs/toc_test.go +++ b/cmd/mungedocs/toc_test.go @@ -29,8 +29,10 @@ func Test_buildTOC(t *testing.T) { }{ {"", ""}, {"Lorem ipsum\ndolor sit amet\n", ""}, - {"# Title\nLorem ipsum \n## Section Heading\ndolor sit amet\n", - "- [Title](#title)\n - [Section Heading](#section-heading)\n"}, + { + "# Title\nLorem ipsum \n## Section Heading\ndolor sit amet\n", + "- [Title](#title)\n - [Section Heading](#section-heading)\n", + }, } for _, c := range cases { actual, err := buildTOC([]byte(c.in)) @@ -47,10 +49,14 @@ func Test_updateTOC(t *testing.T) { out string }{ {"", ""}, - {"Lorem ipsum\ndolor sit amet\n", - "Lorem ipsum\ndolor sit amet\n"}, - {"# Title\nLorem ipsum \n**table of contents**\n\nold cruft\n\n## Section Heading\ndolor sit amet\n", - "# Title\nLorem ipsum \n**table of contents**\n\n- [Title](#title)\n - [Section Heading](#section-heading)\n\n\n## Section Heading\ndolor sit amet\n"}, + { + "Lorem ipsum\ndolor sit amet\n", + "Lorem ipsum\ndolor sit amet\n", + }, + { + "# Title\nLorem ipsum \n**table of contents**\n\nold cruft\n\n## Section Heading\ndolor sit amet\n", + "# Title\nLorem ipsum \n**table of contents**\n\n- [Title](#title)\n - [Section Heading](#section-heading)\n\n\n## Section Heading\ndolor sit amet\n", + }, } for _, c := range cases { actual, err := updateTOC("filename.md", []byte(c.in)) diff --git a/cmd/mungedocs/unversioned_warning.go b/cmd/mungedocs/unversioned_warning.go index 8939fce4532..7768fe38a95 100644 --- a/cmd/mungedocs/unversioned_warning.go +++ b/cmd/mungedocs/unversioned_warning.go @@ -16,9 +16,12 @@ limitations under the License. package main -var beginUnversionedWarning = "" -var endUnversionedWarning = "" -var unversionedWarning = ` +const unversionedWarningTag = "UNVERSIONED_WARNING" + +var beginUnversionedWarning = beginMungeTag(unversionedWarningTag) +var endUnversionedWarning = endMungeTag(unversionedWarningTag) + +const unversionedWarning = `

*** PLEASE NOTE: This document applies to the HEAD of the source diff --git a/cmd/mungedocs/util.go b/cmd/mungedocs/util.go index 8581f5152b9..d4e9773f677 100644 --- a/cmd/mungedocs/util.go +++ b/cmd/mungedocs/util.go @@ -98,3 +98,15 @@ func hasMacroBlock(lines []string, begin string, end string) bool { } return false } + +// Returns the canonical begin-tag for a given description. This does not +// include the trailing newline. +func beginMungeTag(desc string) string { + return fmt.Sprintf("", desc) +} + +// Returns the canonical end-tag for a given description. This does not +// include the trailing newline. +func endMungeTag(desc string) string { + return fmt.Sprintf("", desc) +} diff --git a/docs/networking.md b/docs/networking.md index d9f439c0843..d91081e5f2b 100644 --- a/docs/networking.md +++ b/docs/networking.md @@ -1,6 +1,6 @@ # Networking in Kubernetes **Table of Contents** - + - [Networking in Kubernetes](#networking-in-kubernetes) - [Summary](#summary) - [Docker model](#docker-model) @@ -14,7 +14,7 @@ - [Calico](#calico) - [Other reading](#other-reading) - + Kubernetes approaches networking somewhat differently than Docker does by default. There are 4 distinct networking problems to solve: