[
  {
    "path": ".gitignore",
    "content": "/godocdown/godocdown\n"
  },
  {
    "path": "Makefile",
    "content": ".PHONY: build test install release\n\nbuild test install:\n\t$(MAKE) -C godocdown $@\n\nrelease: build\n\tgodocdown/godocdown -template example.template $(HOME)/go/src/pkg/strings > example.markdown\n\t(cd godocdown && ./godocdown -signature > README.markdown) || false\n\tcp godocdown/README.markdown .\n"
  },
  {
    "path": "README.markdown",
    "content": "# godocdown\n--\nCommand godocdown generates Go documentation in a GitHub-friendly Markdown\nformat.\n\n    $ go get github.com/robertkrimen/godocdown/godocdown\n\n    $ godocdown /path/to/package > README.markdown\n\n    # Generate documentation for the package/command in the current directory\n    $ godocdown > README.markdown\n\n    # Generate standard Markdown\n    $ godocdown -plain .\n\nThis program is targeted at providing nice-looking documentation for GitHub.\nWith this in mind, it generates GitHub Flavored Markdown\n(http://github.github.com/github-flavored-markdown/) by default. This can be\nchanged with the use of the \"plain\" flag to generate standard Markdown.\n\n### Install\n\n    go get github.com/robertkrimen/godocdown/godocdown\n\n\n### Example\n\nhttp://github.com/robertkrimen/godocdown/blob/master/example.markdown\n\n### Usage\n\n    -output=\"\"\n        Write output to a file instead of stdout\n        Write to stdout with -\n\n    -template=\"\"\n        The template file to use\n\n    -no-template=false\n        Disable template processing\n\n    -plain=false\n        Emit standard Markdown, rather than Github Flavored Markdown\n\n    -heading=\"TitleCase1Word\"\n        Heading detection method: 1Word, TitleCase, Title, TitleCase1Word, \"\"\n        For each line of the package declaration, godocdown attempts to detect if\n        a heading is present via a pattern match. If a heading is detected,\n        it prefixes the line with a Markdown heading indicator (typically \"###\").\n\n        1Word: Only a single word on the entire line\n            [A-Za-z0-9_-]+\n\n        TitleCase: A line where each word has the first letter capitalized\n            ([A-Z][A-Za-z0-9_-]\\s*)+\n\n        Title: A line without punctuation (e.g. a period at the end)\n            ([A-Za-z0-9_-]\\s*)+\n\n        TitleCase1Word: The line matches either the TitleCase or 1Word pattern\n\n\n### Templating\n\nIn addition to Markdown rendering, godocdown provides templating via\ntext/template (http://golang.org/pkg/text/template/) for further customization.\nBy putting a file named \".godocdown.template\" (or one from the list below) in\nthe same directory as your package/command, godocdown will know to use the file\nas a template.\n\n    # text/template\n    .godocdown.markdown\n    .godocdown.md\n    .godocdown.template\n    .godocdown.tmpl\n\nA template file can also be specified with the \"-template\" parameter\n\nAlong with the standard template functionality, the starting data argument has\nthe following interface:\n\n    {{ .Emit }}\n    // Emit the standard documentation (what godocdown would emit without a template)\n\n    {{ .EmitHeader }}\n    // Emit the package name and an import line (if one is present/needed)\n\n    {{ .EmitSynopsis }}\n    // Emit the package declaration\n\n    {{ .EmitUsage }}\n    // Emit package usage, which includes a constants section, a variables section,\n    // a functions section, and a types section. In addition, each type may have its own constant,\n    // variable, and/or function/method listing.\n\n    {{ if .IsCommand  }} ... {{ end }}\n    // A boolean indicating whether the given package is a command or a plain package\n\n    {{ .Name }}\n    // The name of the package/command (string)\n\n    {{ .ImportPath }}\n    // The import path for the package (string)\n    // (This field will be the empty string if godocdown is unable to guess it)\n\n--\n**godocdown** http://github.com/robertkrimen/godocdown\n"
  },
  {
    "path": "example/.godocdown.markdown",
    "content": "{{ .Emit }}\n\n{{ .EmitSignature }}\n\n--\nThis was via template\n"
  },
  {
    "path": "example/example.go",
    "content": "/*\nPackage example is an example package with documentation \n\n\t// Here is some code\n\tfunc example() {\n\t\tabc := 1 + 1\n\t}()\n\nInstallation\n\n\t# This is how to install it:\n\t$ curl http://example.com\n\t$ tar xf example.tar.gz -C .\n\t$ ./example &\n\n*/\npackage example\n\n// A constant section\nconst Other = 3\n\n// A variable section\nvar (\n\tThis = 1\n\n\tthis = 0\n\n\n\t// A description of That\n\tThat = 2.1\n)\n\n// Another constant section\nconst (\n\tAnother = 0\n\tAgain = \"this\"\n)\n\n// Example is a function that does nothing\nfunc Example() {\n}\n\n// ExampleType is a type of nothing\n//\t\t\n//\t\t// Here is how to use it:\n//\t\treturn &ExampleType{\n//\t\t\tFirst: 1,\n//\t\t\tSecond: \"second\",\n//\t\t\tnil,\n//\t\t}\ntype ExampleType struct {\n\tFirst int\n\tSecond string\n\tThird float64\n\tParent *ExampleType\n\n\tfirst int\n\thidden string\n}\n\nfunc (ExampleType) Set() bool {\n\treturn false\n}\n\nfunc NewExample() *ExampleType {\n\treturn &ExampleType{}\n}\n"
  },
  {
    "path": "example.markdown",
    "content": "# Example godocdown (strings)\n\nThis markdown was generated with the help of custom template file ([example.template](http://github.com/robertkrimen/godocdown/blob/master/example.template)). To add custom\nmarkdown to your documentation, you can do something like:\n\n    godocdown -template=godocdown.tmpl ...\n\nThe template format is the standard Go text/template: http://golang.org/pkg/text/template\n\nAlong with the standard template functionality, the starting data argument has the following interface:\n\n    {{ .Emit }}\n    // Emit the standard documentation (what godocdown would emit without a template)\n\n    {{ .EmitHeader }}\n    // Emit the package name and an import line (if one is present/needed)\n\n    {{ .EmitSynopsis }}\n    // Emit the package declaration\n\n    {{ .EmitUsage }}\n    // Emit package usage, which includes a constants section, a variables section,\n    // a functions section, and a types section. In addition, each type may have its own constant,\n    // variable, and/or function/method listing.\n\n    {{ if .IsCommand  }} ... {{ end }}\n    // A boolean indicating whether the given package is a command or a plain package\n\n    {{ .Name }}\n    // The name of the package/command (string)\n\n    {{ .ImportPath }}\n    // The import path for the package (string)\n    // (This field will be the empty string if godocdown is unable to guess it)\n\ngodocdown for the http://golang.org/pkg/strings package:\n\n--\n\n# strings\n--\n    import \"strings\"\n\nPackage strings implements simple functions to manipulate strings.\n\n## Usage\n\n#### func  Contains\n\n```go\nfunc Contains(s, substr string) bool\n```\nContains returns true if substr is within s.\n\n#### func  ContainsAny\n\n```go\nfunc ContainsAny(s, chars string) bool\n```\nContainsAny returns true if any Unicode code points in chars are within s.\n\n#### func  ContainsRune\n\n```go\nfunc ContainsRune(s string, r rune) bool\n```\nContainsRune returns true if the Unicode code point r is within s.\n\n#### func  Count\n\n```go\nfunc Count(s, sep string) int\n```\nCount counts the number of non-overlapping instances of sep in s.\n\n#### func  EqualFold\n\n```go\nfunc EqualFold(s, t string) bool\n```\nEqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under\nUnicode case-folding.\n\n#### func  Fields\n\n```go\nfunc Fields(s string) []string\n```\nFields splits the string s around each instance of one or more consecutive white\nspace characters, as defined by unicode.IsSpace, returning an array of\nsubstrings of s or an empty list if s contains only white space.\n\n#### func  FieldsFunc\n\n```go\nfunc FieldsFunc(s string, f func(rune) bool) []string\n```\nFieldsFunc splits the string s at each run of Unicode code points c satisfying\nf(c) and returns an array of slices of s. If all code points in s satisfy f(c)\nor the string is empty, an empty slice is returned.\n\n#### func  HasPrefix\n\n```go\nfunc HasPrefix(s, prefix string) bool\n```\nHasPrefix tests whether the string s begins with prefix.\n\n#### func  HasSuffix\n\n```go\nfunc HasSuffix(s, suffix string) bool\n```\nHasSuffix tests whether the string s ends with suffix.\n\n#### func  Index\n\n```go\nfunc Index(s, sep string) int\n```\nIndex returns the index of the first instance of sep in s, or -1 if sep is not\npresent in s.\n\n#### func  IndexAny\n\n```go\nfunc IndexAny(s, chars string) int\n```\nIndexAny returns the index of the first instance of any Unicode code point from\nchars in s, or -1 if no Unicode code point from chars is present in s.\n\n#### func  IndexFunc\n\n```go\nfunc IndexFunc(s string, f func(rune) bool) int\n```\nIndexFunc returns the index into s of the first Unicode code point satisfying\nf(c), or -1 if none do.\n\n#### func  IndexRune\n\n```go\nfunc IndexRune(s string, r rune) int\n```\nIndexRune returns the index of the first instance of the Unicode code point r,\nor -1 if rune is not present in s.\n\n#### func  Join\n\n```go\nfunc Join(a []string, sep string) string\n```\nJoin concatenates the elements of a to create a single string. The separator\nstring sep is placed between elements in the resulting string.\n\n#### func  LastIndex\n\n```go\nfunc LastIndex(s, sep string) int\n```\nLastIndex returns the index of the last instance of sep in s, or -1 if sep is\nnot present in s.\n\n#### func  LastIndexAny\n\n```go\nfunc LastIndexAny(s, chars string) int\n```\nLastIndexAny returns the index of the last instance of any Unicode code point\nfrom chars in s, or -1 if no Unicode code point from chars is present in s.\n\n#### func  LastIndexFunc\n\n```go\nfunc LastIndexFunc(s string, f func(rune) bool) int\n```\nLastIndexFunc returns the index into s of the last Unicode code point satisfying\nf(c), or -1 if none do.\n\n#### func  Map\n\n```go\nfunc Map(mapping func(rune) rune, s string) string\n```\nMap returns a copy of the string s with all its characters modified according to\nthe mapping function. If mapping returns a negative value, the character is\ndropped from the string with no replacement.\n\n#### func  Repeat\n\n```go\nfunc Repeat(s string, count int) string\n```\nRepeat returns a new string consisting of count copies of the string s.\n\n#### func  Replace\n\n```go\nfunc Replace(s, old, new string, n int) string\n```\nReplace returns a copy of the string s with the first n non-overlapping\ninstances of old replaced by new. If n < 0, there is no limit on the number of\nreplacements.\n\n#### func  Split\n\n```go\nfunc Split(s, sep string) []string\n```\nSplit slices s into all substrings separated by sep and returns a slice of the\nsubstrings between those separators. If sep is empty, Split splits after each\nUTF-8 sequence. It is equivalent to SplitN with a count of -1.\n\n#### func  SplitAfter\n\n```go\nfunc SplitAfter(s, sep string) []string\n```\nSplitAfter slices s into all substrings after each instance of sep and returns a\nslice of those substrings. If sep is empty, SplitAfter splits after each UTF-8\nsequence. It is equivalent to SplitAfterN with a count of -1.\n\n#### func  SplitAfterN\n\n```go\nfunc SplitAfterN(s, sep string, n int) []string\n```\nSplitAfterN slices s into substrings after each instance of sep and returns a\nslice of those substrings. If sep is empty, SplitAfterN splits after each UTF-8\nsequence. The count determines the number of substrings to return:\n\n    n > 0: at most n substrings; the last substring will be the unsplit remainder.\n    n == 0: the result is nil (zero substrings)\n    n < 0: all substrings\n\n#### func  SplitN\n\n```go\nfunc SplitN(s, sep string, n int) []string\n```\nSplitN slices s into substrings separated by sep and returns a slice of the\nsubstrings between those separators. If sep is empty, SplitN splits after each\nUTF-8 sequence. The count determines the number of substrings to return:\n\n    n > 0: at most n substrings; the last substring will be the unsplit remainder.\n    n == 0: the result is nil (zero substrings)\n    n < 0: all substrings\n\n#### func  Title\n\n```go\nfunc Title(s string) string\n```\nTitle returns a copy of the string s with all Unicode letters that begin words\nmapped to their title case.\n\nBUG: The rule Title uses for word boundaries does not handle Unicode punctuation\nproperly.\n\n#### func  ToLower\n\n```go\nfunc ToLower(s string) string\n```\nToLower returns a copy of the string s with all Unicode letters mapped to their\nlower case.\n\n#### func  ToLowerSpecial\n\n```go\nfunc ToLowerSpecial(_case unicode.SpecialCase, s string) string\n```\nToLowerSpecial returns a copy of the string s with all Unicode letters mapped to\ntheir lower case, giving priority to the special casing rules.\n\n#### func  ToTitle\n\n```go\nfunc ToTitle(s string) string\n```\nToTitle returns a copy of the string s with all Unicode letters mapped to their\ntitle case.\n\n#### func  ToTitleSpecial\n\n```go\nfunc ToTitleSpecial(_case unicode.SpecialCase, s string) string\n```\nToTitleSpecial returns a copy of the string s with all Unicode letters mapped to\ntheir title case, giving priority to the special casing rules.\n\n#### func  ToUpper\n\n```go\nfunc ToUpper(s string) string\n```\nToUpper returns a copy of the string s with all Unicode letters mapped to their\nupper case.\n\n#### func  ToUpperSpecial\n\n```go\nfunc ToUpperSpecial(_case unicode.SpecialCase, s string) string\n```\nToUpperSpecial returns a copy of the string s with all Unicode letters mapped to\ntheir upper case, giving priority to the special casing rules.\n\n#### func  Trim\n\n```go\nfunc Trim(s string, cutset string) string\n```\nTrim returns a slice of the string s with all leading and trailing Unicode code\npoints contained in cutset removed.\n\n#### func  TrimFunc\n\n```go\nfunc TrimFunc(s string, f func(rune) bool) string\n```\nTrimFunc returns a slice of the string s with all leading and trailing Unicode\ncode points c satisfying f(c) removed.\n\n#### func  TrimLeft\n\n```go\nfunc TrimLeft(s string, cutset string) string\n```\nTrimLeft returns a slice of the string s with all leading Unicode code points\ncontained in cutset removed.\n\n#### func  TrimLeftFunc\n\n```go\nfunc TrimLeftFunc(s string, f func(rune) bool) string\n```\nTrimLeftFunc returns a slice of the string s with all leading Unicode code\npoints c satisfying f(c) removed.\n\n#### func  TrimPrefix\n\n```go\nfunc TrimPrefix(s, prefix string) string\n```\nTrimPrefix returns s without the provided leading prefix string. If s doesn't\nstart with prefix, s is returned unchanged.\n\n#### func  TrimRight\n\n```go\nfunc TrimRight(s string, cutset string) string\n```\nTrimRight returns a slice of the string s, with all trailing Unicode code points\ncontained in cutset removed.\n\n#### func  TrimRightFunc\n\n```go\nfunc TrimRightFunc(s string, f func(rune) bool) string\n```\nTrimRightFunc returns a slice of the string s with all trailing Unicode code\npoints c satisfying f(c) removed.\n\n#### func  TrimSpace\n\n```go\nfunc TrimSpace(s string) string\n```\nTrimSpace returns a slice of the string s, with all leading and trailing white\nspace removed, as defined by Unicode.\n\n#### func  TrimSuffix\n\n```go\nfunc TrimSuffix(s, suffix string) string\n```\nTrimSuffix returns s without the provided trailing suffix string. If s doesn't\nend with suffix, s is returned unchanged.\n\n#### type Reader\n\n```go\ntype Reader struct {\n}\n```\n\nA Reader implements the io.Reader, io.ReaderAt, io.Seeker, io.WriterTo,\nio.ByteScanner, and io.RuneScanner interfaces by reading from a string.\n\n#### func  NewReader\n\n```go\nfunc NewReader(s string) *Reader\n```\nNewReader returns a new Reader reading from s. It is similar to\nbytes.NewBufferString but more efficient and read-only.\n\n#### func (*Reader) Len\n\n```go\nfunc (r *Reader) Len() int\n```\nLen returns the number of bytes of the unread portion of the string.\n\n#### func (*Reader) Read\n\n```go\nfunc (r *Reader) Read(b []byte) (n int, err error)\n```\n\n#### func (*Reader) ReadAt\n\n```go\nfunc (r *Reader) ReadAt(b []byte, off int64) (n int, err error)\n```\n\n#### func (*Reader) ReadByte\n\n```go\nfunc (r *Reader) ReadByte() (b byte, err error)\n```\n\n#### func (*Reader) ReadRune\n\n```go\nfunc (r *Reader) ReadRune() (ch rune, size int, err error)\n```\n\n#### func (*Reader) Seek\n\n```go\nfunc (r *Reader) Seek(offset int64, whence int) (int64, error)\n```\nSeek implements the io.Seeker interface.\n\n#### func (*Reader) UnreadByte\n\n```go\nfunc (r *Reader) UnreadByte() error\n```\n\n#### func (*Reader) UnreadRune\n\n```go\nfunc (r *Reader) UnreadRune() error\n```\n\n#### func (*Reader) WriteTo\n\n```go\nfunc (r *Reader) WriteTo(w io.Writer) (n int64, err error)\n```\nWriteTo implements the io.WriterTo interface.\n\n#### type Replacer\n\n```go\ntype Replacer struct {\n}\n```\n\nA Replacer replaces a list of strings with replacements.\n\n#### func  NewReplacer\n\n```go\nfunc NewReplacer(oldnew ...string) *Replacer\n```\nNewReplacer returns a new Replacer from a list of old, new string pairs.\nReplacements are performed in order, without overlapping matches.\n\n#### func (*Replacer) Replace\n\n```go\nfunc (r *Replacer) Replace(s string) string\n```\nReplace returns a copy of s with all replacements performed.\n\n#### func (*Replacer) WriteString\n\n```go\nfunc (r *Replacer) WriteString(w io.Writer, s string) (n int, err error)\n```\nWriteString writes s to w with all replacements performed.\n"
  },
  {
    "path": "example.template",
    "content": "# Example godocdown (strings)\n\nThis markdown was generated with the help of custom template file ([example.template](http://github.com/robertkrimen/godocdown/blob/master/example.template)). To add custom\nmarkdown to your documentation, you can do something like:\n\n    godocdown -template=godocdown.tmpl ...\n\nThe template format is the standard Go text/template: http://golang.org/pkg/text/template\n\nAlong with the standard template functionality, the starting data argument has the following interface:\n\n    {{ \"{{ .Emit }}\" }}\n    // Emit the standard documentation (what godocdown would emit without a template)\n\n    {{ \"{{ .EmitHeader }}\" }}\n    // Emit the package name and an import line (if one is present/needed)\n\n    {{ \"{{ .EmitSynopsis }}\" }}\n    // Emit the package declaration\n\n    {{ \"{{ .EmitUsage }}\" }}\n    // Emit package usage, which includes a constants section, a variables section,\n    // a functions section, and a types section. In addition, each type may have its own constant,\n    // variable, and/or function/method listing.\n\n    {{ \"{{ if .IsCommand  }} ... {{ end }}\" }}\n    // A boolean indicating whether the given package is a command or a plain package\n\n    {{ \"{{ .Name }}\" }}\n    // The name of the package/command (string)\n\n    {{ \"{{ .ImportPath }}\" }}\n    // The import path for the package (string)\n    // (This field will be the empty string if godocdown is unable to guess it)\n\ngodocdown for the http://golang.org/pkg/strings package:\n\n--\n\n{{ .Emit }}\n"
  },
  {
    "path": "godocdown/.test/godocdown.markdown/.godocdown.markdown",
    "content": ""
  },
  {
    "path": "godocdown/.test/godocdown.markdown/.godocdown.md",
    "content": ""
  },
  {
    "path": "godocdown/.test/godocdown.markdown/.godocdown.template",
    "content": ""
  },
  {
    "path": "godocdown/.test/godocdown.markdown/.godocdown.tmpl",
    "content": ""
  },
  {
    "path": "godocdown/.test/godocdown.md/.godocdown.md",
    "content": ""
  },
  {
    "path": "godocdown/.test/godocdown.md/.godocdown.template",
    "content": ""
  },
  {
    "path": "godocdown/.test/godocdown.md/.godocdown.tmpl",
    "content": ""
  },
  {
    "path": "godocdown/.test/godocdown.template/.godocdown.template",
    "content": ""
  },
  {
    "path": "godocdown/.test/godocdown.template/.godocdown.tmpl",
    "content": ""
  },
  {
    "path": "godocdown/.test/godocdown.tmpl/.godocdown.tmpl",
    "content": ""
  },
  {
    "path": "godocdown/.test/issue3/issue3.go",
    "content": "//  Documentation for package issue3\n//\n//  Nothing happens.\n//\n//      Some code happens.\npackage issue3\n\n//  Documentation for func Test()\n//\n//  Something happens.\n//\n//      Some code happens.\nfunc Test() {\n}\n"
  },
  {
    "path": "godocdown/7f_shim",
    "content": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\n\nmy @input = <STDIN>;\nmy $longest = 0;\nfor (@input) {\n    chomp;\n    s/\\s*\\x{7f}\\s*$//;\n    my $length = length $_;\n    if ($length > $longest) {\n        $longest = $length;\n    }\n}\n$longest += 4;\nfor (@input) {\n    chomp;\n    my $length = length $_;\n    print $_;\n    print \" \" x ($longest - $length);\n    print \"\\x{7f}\\n\";\n}\n"
  },
  {
    "path": "godocdown/Makefile",
    "content": ".PHONY: build test test-example install release\n\nbuild: test\n\tgo build\n\ntest:\n\tgo test -i\n\tgo test\n\ntest-example: build\n\t./godocdown -signature example > test/README.markdown\n\t#cd test && git commit -m 'WIP' * && git push\n\ninstall:\n\tgo install\n\nrelease:\n\t$(MAKE) -C .. $@\n"
  },
  {
    "path": "godocdown/README.markdown",
    "content": "# godocdown\n--\nCommand godocdown generates Go documentation in a GitHub-friendly Markdown\nformat.\n\n    $ go get github.com/robertkrimen/godocdown/godocdown\n\n    $ godocdown /path/to/package > README.markdown\n\n    # Generate documentation for the package/command in the current directory\n    $ godocdown > README.markdown\n\n    # Generate standard Markdown\n    $ godocdown -plain .\n\nThis program is targeted at providing nice-looking documentation for GitHub.\nWith this in mind, it generates GitHub Flavored Markdown\n(http://github.github.com/github-flavored-markdown/) by default. This can be\nchanged with the use of the \"plain\" flag to generate standard Markdown.\n\n### Install\n\n    go get github.com/robertkrimen/godocdown/godocdown\n\n\n### Example\n\nhttp://github.com/robertkrimen/godocdown/blob/master/example.markdown\n\n### Usage\n\n    -output=\"\"\n        Write output to a file instead of stdout\n        Write to stdout with -\n\n    -template=\"\"\n        The template file to use\n\n    -no-template=false\n        Disable template processing\n\n    -plain=false\n        Emit standard Markdown, rather than Github Flavored Markdown\n\n    -heading=\"TitleCase1Word\"\n        Heading detection method: 1Word, TitleCase, Title, TitleCase1Word, \"\"\n        For each line of the package declaration, godocdown attempts to detect if\n        a heading is present via a pattern match. If a heading is detected,\n        it prefixes the line with a Markdown heading indicator (typically \"###\").\n\n        1Word: Only a single word on the entire line\n            [A-Za-z0-9_-]+\n\n        TitleCase: A line where each word has the first letter capitalized\n            ([A-Z][A-Za-z0-9_-]\\s*)+\n\n        Title: A line without punctuation (e.g. a period at the end)\n            ([A-Za-z0-9_-]\\s*)+\n\n        TitleCase1Word: The line matches either the TitleCase or 1Word pattern\n\n\n### Templating\n\nIn addition to Markdown rendering, godocdown provides templating via\ntext/template (http://golang.org/pkg/text/template/) for further customization.\nBy putting a file named \".godocdown.template\" (or one from the list below) in\nthe same directory as your package/command, godocdown will know to use the file\nas a template.\n\n    # text/template\n    .godocdown.markdown\n    .godocdown.md\n    .godocdown.template\n    .godocdown.tmpl\n\nA template file can also be specified with the \"-template\" parameter\n\nAlong with the standard template functionality, the starting data argument has\nthe following interface:\n\n    {{ .Emit }}\n    // Emit the standard documentation (what godocdown would emit without a template)\n\n    {{ .EmitHeader }}\n    // Emit the package name and an import line (if one is present/needed)\n\n    {{ .EmitSynopsis }}\n    // Emit the package declaration\n\n    {{ .EmitUsage }}\n    // Emit package usage, which includes a constants section, a variables section,\n    // a functions section, and a types section. In addition, each type may have its own constant,\n    // variable, and/or function/method listing.\n\n    {{ if .IsCommand  }} ... {{ end }}\n    // A boolean indicating whether the given package is a command or a plain package\n\n    {{ .Name }}\n    // The name of the package/command (string)\n\n    {{ .ImportPath }}\n    // The import path for the package (string)\n    // (This field will be the empty string if godocdown is unable to guess it)\n\n--\n**godocdown** http://github.com/robertkrimen/godocdown\n"
  },
  {
    "path": "godocdown/dbg/dbg.go",
    "content": "// This file was AUTOMATICALLY GENERATED by dbg-import (smuggol) from github.com/robertkrimen/dbg\n\n/*\nPackage dbg is a println/printf/log-debugging utility library.\n\n    import (\n        Dbg \"github.com/robertkrimen/dbg\"\n    )\n\n    dbg, dbgf := Dbg.New()\n\n    dbg(\"Emit some debug stuff\", []byte{120, 121, 122, 122, 121}, math.Pi)\n    # \"2013/01/28 16:50:03 Emit some debug stuff [120 121 122 122 121] 3.141592653589793\"\n\n    dbgf(\"With a %s formatting %.2f\", \"little\", math.Pi)\n    # \"2013/01/28 16:51:55 With a little formatting (3.14)\"\n\n    dbgf(\"%/fatal//A fatal debug statement: should not be here\")\n    # \"A fatal debug statement: should not be here\"\n    # ...and then, os.Exit(1)\n\n    dbgf(\"%/panic//Can also panic %s\", \"this\")\n    # \"Can also panic this\"\n    # ...as a panic, equivalent to: panic(\"Can also panic this\")\n\n    dbgf(\"Any %s arguments without a corresponding %%\", \"extra\", \"are treated like arguments to dbg()\")\n    # \"2013/01/28 17:14:40 Any extra arguments (without a corresponding %) are treated like arguments to dbg()\"\n\n    dbgf(\"%d %d\", 1, 2, 3, 4, 5)\n    # \"2013/01/28 17:16:32 Another example: 1 2 3 4 5\"\n\n    dbgf(\"%@: Include the function name for a little context (via %s)\", \"%@\")\n    # \"2013... github.com/robertkrimen/dbg.TestSynopsis: Include the function name for a little context (via %@)\"\n\nBy default, dbg uses log (log.Println, log.Printf, log.Panic, etc.) for output.\nHowever, you can also provide your own output destination by invoking dbg.New with\na customization function:\n\n    import (\n        \"bytes\"\n        Dbg \"github.com/robertkrimen/dbg\"\n        \"os\"\n    )\n\n    # dbg to os.Stderr\n    dbg, dbgf := Dbg.New(func(dbgr *Dbgr) {\n        dbgr.SetOutput(os.Stderr)\n    })\n\n    # A slightly contrived example:\n    var buffer bytes.Buffer\n    dbg, dbgf := New(func(dbgr *Dbgr) {\n        dbgr.SetOutput(&buffer)\n    })\n\n*/\npackage dbg\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"os\"\n\t\"regexp\"\n\t\"runtime\"\n\t\"strings\"\n\t\"unicode\"\n)\n\ntype _frmt struct {\n\tctl          string\n\tformat       string\n\toperandCount int\n\tpanic        bool\n\tfatal        bool\n\tcheck        bool\n}\n\nvar (\n\tctlTest = regexp.MustCompile(`^\\s*%/`)\n\tctlScan = regexp.MustCompile(`%?/(panic|fatal|check)(?:\\s|$)`)\n)\n\nfunc operandCount(format string) int {\n\tcount := 0\n\tend := len(format)\n\tfor at := 0; at < end; {\n\t\tfor at < end && format[at] != '%' {\n\t\t\tat++\n\t\t}\n\t\tat++\n\t\tif at < end {\n\t\t\tif format[at] != '%' && format[at] != '@' {\n\t\t\t\tcount++\n\t\t\t}\n\t\t\tat++\n\t\t}\n\t}\n\treturn count\n}\n\nfunc parseFormat(format string) (frmt _frmt) {\n\tif ctlTest.MatchString(format) {\n\t\tformat = strings.TrimLeftFunc(format, unicode.IsSpace)\n\t\tindex := strings.Index(format, \"//\")\n\t\tif index != -1 {\n\t\t\tfrmt.ctl = format[0:index]\n\t\t\tformat = format[index+2:] // Skip the second slash via +2 (instead of +1)\n\t\t} else {\n\t\t\tfrmt.ctl = format\n\t\t\tformat = \"\"\n\t\t}\n\t\tfor _, tmp := range ctlScan.FindAllStringSubmatch(frmt.ctl, -1) {\n\t\t\tfor _, value := range tmp[1:] {\n\t\t\t\tswitch value {\n\t\t\t\tcase \"panic\":\n\t\t\t\t\tfrmt.panic = true\n\t\t\t\tcase \"fatal\":\n\t\t\t\t\tfrmt.fatal = true\n\t\t\t\tcase \"check\":\n\t\t\t\t\tfrmt.check = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfrmt.format = format\n\tfrmt.operandCount = operandCount(format)\n\treturn\n}\n\ntype Dbgr struct {\n\temit _emit\n}\n\ntype DbgFunction func(values ...interface{})\n\nfunc NewDbgr() *Dbgr {\n\tself := &Dbgr{}\n\treturn self\n}\n\n/*\nNew will create and return a pair of debugging functions. You can customize where\nthey output to by passing in an (optional) customization function:\n\n    import (\n        Dbg \"github.com/robertkrimen/dbg\"\n        \"os\"\n    )\n\n    # dbg to os.Stderr\n    dbg, dbgf := Dbg.New(func(dbgr *Dbgr) {\n        dbgr.SetOutput(os.Stderr)\n    })\n\n*/\nfunc New(options ...interface{}) (dbg DbgFunction, dbgf DbgFunction) {\n\tdbgr := NewDbgr()\n\tif len(options) > 0 {\n\t\tif fn, ok := options[0].(func(*Dbgr)); ok {\n\t\t\tfn(dbgr)\n\t\t}\n\t}\n\treturn dbgr.DbgDbgf()\n}\n\nfunc (self Dbgr) Dbg(values ...interface{}) {\n\tself.getEmit().emit(_frmt{}, \"\", values...)\n}\n\nfunc (self Dbgr) Dbgf(values ...interface{}) {\n\tself.dbgf(values...)\n}\n\nfunc (self Dbgr) DbgDbgf() (dbg DbgFunction, dbgf DbgFunction) {\n\tdbg = func(vl ...interface{}) {\n\t\tself.Dbg(vl...)\n\t}\n\tdbgf = func(vl ...interface{}) {\n\t\tself.dbgf(vl...)\n\t}\n\treturn dbg, dbgf // Redundant, but...\n}\n\nfunc (self Dbgr) dbgf(values ...interface{}) {\n\n\tvar frmt _frmt\n\tif len(values) > 0 {\n\t\ttmp := fmt.Sprint(values[0])\n\t\tfrmt = parseFormat(tmp)\n\t\tvalues = values[1:]\n\t}\n\n\tbuffer_f := bytes.Buffer{}\n\tformat := frmt.format\n\tend := len(format)\n\tfor at := 0; at < end; {\n\t\tlast := at\n\t\tfor at < end && format[at] != '%' {\n\t\t\tat++\n\t\t}\n\t\tif at > last {\n\t\t\tbuffer_f.WriteString(format[last:at])\n\t\t}\n\t\tif at >= end {\n\t\t\tbreak\n\t\t}\n\t\t// format[at] == '%'\n\t\tat++\n\t\t// format[at] == ?\n\t\tif format[at] == '@' {\n\t\t\tdepth := 2\n\t\t\tpc, _, _, _ := runtime.Caller(depth)\n\t\t\tname := runtime.FuncForPC(pc).Name()\n\t\t\tbuffer_f.WriteString(name)\n\t\t} else {\n\t\t\tbuffer_f.WriteString(format[at-1 : at+1])\n\t\t}\n\t\tat++\n\t}\n\n\t//values_f := append([]interface{}{}, values[0:frmt.operandCount]...)\n\tvalues_f := values[0:frmt.operandCount]\n\tvalues_dbg := values[frmt.operandCount:]\n\tif len(values_dbg) > 0 {\n\t\t// Adjust frmt.format:\n\t\t// (%v instead of %s because: frmt.check)\n\t\t{\n\t\t\ttmp := format\n\t\t\tif len(tmp) > 0 {\n\t\t\t\tif unicode.IsSpace(rune(tmp[len(tmp)-1])) {\n\t\t\t\t\tbuffer_f.WriteString(\"%v\")\n\t\t\t\t} else {\n\t\t\t\t\tbuffer_f.WriteString(\" %v\")\n\t\t\t\t}\n\t\t\t} else if frmt.check {\n\t\t\t\t// Performing a check, so no output\n\t\t\t} else {\n\t\t\t\tbuffer_f.WriteString(\"%v\")\n\t\t\t}\n\t\t}\n\n\t\t// Adjust values_f:\n\t\tif !frmt.check {\n\t\t\ttmp := []string{}\n\t\t\tfor _, value := range values_dbg {\n\t\t\t\ttmp = append(tmp, fmt.Sprintf(\"%v\", value))\n\t\t\t}\n\t\t\t// First, make a copy of values_f, so we avoid overwriting values_dbg when appending\n\t\t\tvalues_f = append([]interface{}{}, values_f...)\n\t\t\tvalues_f = append(values_f, strings.Join(tmp, \" \"))\n\t\t}\n\t}\n\n\tformat = buffer_f.String()\n\tif frmt.check {\n\t\t// We do not actually emit to the log, but panic if\n\t\t// a non-nil value is detected (e.g. a non-nil error)\n\t\tfor _, value := range values_dbg {\n\t\t\tif value != nil {\n\t\t\t\tif format == \"\" {\n\t\t\t\t\tpanic(value)\n\t\t\t\t} else {\n\t\t\t\t\tpanic(fmt.Sprintf(format, append(values_f, value)...))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tself.getEmit().emit(frmt, format, values_f...)\n\t}\n}\n\n// Idiot-proof &Dbgr{}, etc.\nfunc (self *Dbgr) getEmit() _emit {\n\tif self.emit == nil {\n\t\tself.emit = standardEmit()\n\t}\n\treturn self.emit\n}\n\n// SetOutput will accept the following as a destination for output:\n//\n//      *log.Logger         Print*/Panic*/Fatal* of the logger\n//      io.Writer           - \n//      nil                 Reset to the default output (os.Stderr)\n//      \"log\"               Print*/Panic*/Fatal* via the \"log\" package\n//\nfunc (self *Dbgr) SetOutput(output interface{}) {\n\tif output == nil {\n\t\tself.emit = standardEmit()\n\t\treturn\n\t}\n\tswitch output := output.(type) {\n\tcase *log.Logger:\n\t\tself.emit = _emitLogger{\n\t\t\tlogger: output,\n\t\t}\n\t\treturn\n\tcase io.Writer:\n\t\tself.emit = _emitWriter{\n\t\t\twriter: output,\n\t\t}\n\t\treturn\n\tcase string:\n\t\tif output == \"log\" {\n\t\t\tself.emit = _emitLog{}\n\t\t\treturn\n\t\t}\n\t}\n\tpanic(output)\n}\n\n// ======== //\n// = emit = //\n// ======== //\n\nfunc standardEmit() _emit {\n\treturn _emitWriter{\n\t\twriter: os.Stderr,\n\t}\n}\n\nfunc ln(tmp string) string {\n\tlength := len(tmp)\n\tif length > 0 && tmp[length-1] != '\\n' {\n\t\treturn tmp + \"\\n\"\n\t}\n\treturn tmp\n}\n\ntype _emit interface {\n\temit(_frmt, string, ...interface{})\n}\n\ntype _emitWriter struct {\n\twriter io.Writer\n}\n\nfunc (self _emitWriter) emit(frmt _frmt, format string, values ...interface{}) {\n\tif format == \"\" {\n\t\tfmt.Fprintln(self.writer, values...)\n\t} else {\n\t\tif frmt.panic {\n\t\t\tpanic(fmt.Sprintf(format, values...))\n\t\t}\n\t\tfmt.Fprintf(self.writer, ln(format), values...)\n\t\tif frmt.fatal {\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}\n\ntype _emitLogger struct {\n\tlogger *log.Logger\n}\n\nfunc (self _emitLogger) emit(frmt _frmt, format string, values ...interface{}) {\n\tif format == \"\" {\n\t\tself.logger.Println(values...)\n\t} else {\n\t\tif frmt.panic {\n\t\t\tself.logger.Panicf(format, values...)\n\t\t} else if frmt.fatal {\n\t\t\tself.logger.Fatalf(format, values...)\n\t\t} else {\n\t\t\tself.logger.Printf(format, values...)\n\t\t}\n\t}\n}\n\ntype _emitLog struct {\n}\n\nfunc (self _emitLog) emit(frmt _frmt, format string, values ...interface{}) {\n\tif format == \"\" {\n\t\tlog.Println(values...)\n\t} else {\n\t\tif frmt.panic {\n\t\t\tlog.Panicf(format, values...)\n\t\t} else if frmt.fatal {\n\t\t\tlog.Fatalf(format, values...)\n\t\t} else {\n\t\t\tlog.Printf(format, values...)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "godocdown/dbg.go",
    "content": "// This file was AUTOMATICALLY GENERATED by dbg-import (smuggol) for github.com/robertkrimen/dbg\n\npackage main\n\nimport (\n\tDbg \"github.com/robertkrimen/godocdown/godocdown/dbg\"\n)\n\nvar dbg, dbgf = Dbg.New()\n"
  },
  {
    "path": "godocdown/go_doc_totext.go",
    "content": "package main\n\n// Our own, slightly different version of ToText.\n\nimport (\n\t\"io\"\n\t\"regexp\"\n\t\"strings\"\n\t\"unicode\"\n\t\"unicode/utf8\"\n)\n\nvar (\n\tldquo = []byte(\"&ldquo;\")\n\trdquo = []byte(\"&rdquo;\")\n)\n\nconst (\n\t// Regexp for Go identifiers\n\tidentRx = `[a-zA-Z_][a-zA-Z_0-9]*` // TODO(gri) ASCII only for now - fix this\n\n\t// Regexp for URLs\n\tprotocol = `(https?|ftp|file|gopher|mailto|news|nntp|telnet|wais|prospero):`\n\thostPart = `[a-zA-Z0-9_@\\-]+`\n\tfilePart = `[a-zA-Z0-9_?%#~&/\\-+=]+`\n\turlRx    = protocol + `//` + // http://\n\t\thostPart + `([.:]` + hostPart + `)*/?` + // //www.google.com:8080/\n\t\tfilePart + `([:.,]` + filePart + `)*`\n)\n\nvar matchRx = regexp.MustCompile(`(` + urlRx + `)|(` + identRx + `)`)\n\nfunc indentLen(s string) int {\n\ti := 0\n\tfor i < len(s) && (s[i] == ' ' || s[i] == '\\t') {\n\t\ti++\n\t}\n\treturn i\n}\n\nfunc isBlank(s string) bool {\n\treturn len(s) == 0 || (len(s) == 1 && s[0] == '\\n')\n}\n\nfunc commonPrefix(a, b string) string {\n\ti := 0\n\tfor i < len(a) && i < len(b) && a[i] == b[i] {\n\t\ti++\n\t}\n\treturn a[0:i]\n}\n\nfunc unindent(block []string) {\n\tif len(block) == 0 {\n\t\treturn\n\t}\n\n\t// compute maximum common white prefix\n\tprefix := block[0][0:indentLen(block[0])]\n\tfor _, line := range block {\n\t\tif !isBlank(line) {\n\t\t\tprefix = commonPrefix(prefix, line[0:indentLen(line)])\n\t\t}\n\t}\n\tn := len(prefix)\n\n\t// remove\n\tfor i, line := range block {\n\t\tif !isBlank(line) {\n\t\t\tblock[i] = line[n:]\n\t\t}\n\t}\n}\n\n// heading returns the trimmed line if it passes as a section heading;\n// otherwise it returns the empty string.\nfunc heading(line string) string {\n\tline = strings.TrimSpace(line)\n\tif len(line) == 0 {\n\t\treturn \"\"\n\t}\n\n\t// a heading must start with an uppercase letter\n\tr, _ := utf8.DecodeRuneInString(line)\n\tif !unicode.IsLetter(r) || !unicode.IsUpper(r) {\n\t\treturn \"\"\n\t}\n\n\t// it must end in a letter or digit:\n\tr, _ = utf8.DecodeLastRuneInString(line)\n\tif !unicode.IsLetter(r) && !unicode.IsDigit(r) {\n\t\treturn \"\"\n\t}\n\n\t// exclude lines with illegal characters\n\tif strings.IndexAny(line, \",.;:!?+*/=()[]{}_^°&§~%#@<\\\">\\\\\") >= 0 {\n\t\treturn \"\"\n\t}\n\n\t// allow \"'\" for possessive \"'s\" only\n\tfor b := line; ; {\n\t\ti := strings.IndexRune(b, '\\'')\n\t\tif i < 0 {\n\t\t\tbreak\n\t\t}\n\t\tif i+1 >= len(b) || b[i+1] != 's' || (i+2 < len(b) && b[i+2] != ' ') {\n\t\t\treturn \"\" // not followed by \"s \"\n\t\t}\n\t\tb = b[i+2:]\n\t}\n\n\treturn line\n}\n\ntype op int\n\nconst (\n\topPara op = iota\n\topHead\n\topPre\n)\n\ntype block struct {\n\top    op\n\tlines []string\n}\n\nvar nonAlphaNumRx = regexp.MustCompile(`[^a-zA-Z0-9]`)\n\nfunc anchorID(line string) string {\n\t// Add a \"hdr-\" prefix to avoid conflicting with IDs used for package symbols.\n\treturn \"hdr-\" + nonAlphaNumRx.ReplaceAllString(line, \"_\")\n}\n\nfunc blocks(text string) []block {\n\tvar (\n\t\tout  []block\n\t\tpara []string\n\n\t\tlastWasBlank   = false\n\t\tlastWasHeading = false\n\t)\n\n\tclose := func() {\n\t\tif para != nil {\n\t\t\tout = append(out, block{opPara, para})\n\t\t\tpara = nil\n\t\t}\n\t}\n\n\tlines := strings.SplitAfter(text, \"\\n\")\n\tunindent(lines)\n\tfor i := 0; i < len(lines); {\n\t\tline := lines[i]\n\t\tif isBlank(line) {\n\t\t\t// close paragraph\n\t\t\tclose()\n\t\t\ti++\n\t\t\tlastWasBlank = true\n\t\t\tcontinue\n\t\t}\n\t\tif indentLen(line) > 0 {\n\t\t\t// close paragraph\n\t\t\tclose()\n\n\t\t\t// count indented or blank lines\n\t\t\tj := i + 1\n\t\t\tfor j < len(lines) && (isBlank(lines[j]) || indentLen(lines[j]) > 0) {\n\t\t\t\tj++\n\t\t\t}\n\t\t\t// but not trailing blank lines\n\t\t\tfor j > i && isBlank(lines[j-1]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tpre := lines[i:j]\n\t\t\ti = j\n\n\t\t\tunindent(pre)\n\n\t\t\t// put those lines in a pre block\n\t\t\tout = append(out, block{opPre, pre})\n\t\t\tlastWasHeading = false\n\t\t\tcontinue\n\t\t}\n\n\t\tif lastWasBlank && !lastWasHeading && i+2 < len(lines) &&\n\t\t\tisBlank(lines[i+1]) && !isBlank(lines[i+2]) && indentLen(lines[i+2]) == 0 {\n\t\t\t// current line is non-blank, surrounded by blank lines\n\t\t\t// and the next non-blank line is not indented: this\n\t\t\t// might be a heading.\n\t\t\tif head := heading(line); head != \"\" {\n\t\t\t\tclose()\n\t\t\t\tout = append(out, block{opHead, []string{head}})\n\t\t\t\ti += 2\n\t\t\t\tlastWasHeading = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\t// open paragraph\n\t\tlastWasBlank = false\n\t\tlastWasHeading = false\n\t\tpara = append(para, lines[i])\n\t\ti++\n\t}\n\tclose()\n\n\treturn out\n}\n\n// ToText prepares comment text for presentation in textual output.\n// It wraps paragraphs of text to width or fewer Unicode code points\n// and then prefixes each line with the indent.  In preformatted sections\n// (such as program text), it prefixes each non-blank line with preIndent.\nfunc toText(w io.Writer, text string, indent, preIndent string, width int) {\n\tl := lineWrapper{\n\t\tout:    w,\n\t\twidth:  width,\n\t\tindent: indent,\n\t}\n\tfor _, b := range blocks(text) {\n\t\tswitch b.op {\n\t\tcase opPara:\n\t\t\t// l.write will add leading newline if required\n\t\t\tfor _, line := range b.lines {\n\t\t\t\tl.write(line)\n\t\t\t}\n\t\t\tl.flush()\n\t\tcase opHead:\n\t\t\tw.Write(nl)\n\t\t\tfor _, line := range b.lines {\n\t\t\t\tl.write(line + \"\\n\")\n\t\t\t}\n\t\t\tl.flush()\n\t\tcase opPre:\n\t\t\tw.Write(nl)\n\t\t\tfor _, line := range b.lines {\n\t\t\t\tif !isBlank(line) {\n\t\t\t\t\tw.Write([]byte(preIndent))\n\t\t\t\t\tw.Write([]byte(line))\n\t\t\t\t} else {\n\t\t\t\t\tw.Write([]byte(line))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\ntype lineWrapper struct {\n\tout       io.Writer\n\tprinted   bool\n\twidth     int\n\tindent    string\n\tn         int\n\tpendSpace int\n}\n\nvar nl = []byte(\"\\n\")\nvar space = []byte(\" \")\n\nfunc (l *lineWrapper) write(text string) {\n\tif l.n == 0 && l.printed {\n\t\tl.out.Write(nl) // blank line before new paragraph\n\t}\n\tl.printed = true\n\n\tfor _, f := range strings.Fields(text) {\n\t\tw := utf8.RuneCountInString(f)\n\t\t// wrap if line is too long\n\t\tif l.n > 0 && l.n+l.pendSpace+w > l.width {\n\t\t\tl.out.Write(nl)\n\t\t\tl.n = 0\n\t\t\tl.pendSpace = 0\n\t\t}\n\t\tif l.n == 0 {\n\t\t\tl.out.Write([]byte(l.indent))\n\t\t}\n\t\tl.out.Write(space[:l.pendSpace])\n\t\tl.out.Write([]byte(f))\n\t\tl.n += l.pendSpace + w\n\t\tl.pendSpace = 1\n\t}\n}\n\nfunc (l *lineWrapper) flush() {\n\tif l.n == 0 {\n\t\treturn\n\t}\n\tl.out.Write(nl)\n\tl.pendSpace = 0\n\tl.n = 0\n}\n"
  },
  {
    "path": "godocdown/kilt/at.go",
    "content": "// This file was AUTOMATICALLY GENERATED by kilt-import (smuggol) from github.com/robertkrimen/kilt\n\npackage kilt\n\nimport (\n\t\"os\"\n)\n\n// At\nfunc (self Kilt) At(there string, fn func() error) []error {\n\treturn At(there, fn)\n}\n\nfunc At(there string, fn func() error) (err []error) {\n\torigin, err_ := os.Getwd()\n\tif err_ != nil {\n\t\torigin = \"\"\n\t\treturn []error{err_, nil}\n\t}\n\terr_ = os.Chdir(there)\n\tif err_ != nil {\n\t\torigin = \"\"\n\t\treturn []error{err_, nil}\n\t}\n\tdefer func() {\n\t\tif origin != \"\" {\n\t\t\terr_ = os.Chdir(origin)\n\t\t\tif err != nil {\n\t\t\t\terr[0] = err_\n\t\t\t} else {\n\t\t\t\terr = []error{err_, nil}\n\t\t\t}\n\t\t}\n\t}()\n\terr_ = fn()\n\tif err_ != nil {\n\t\treturn []error{nil, err_}\n\t}\n\treturn nil\n}\n"
  },
  {
    "path": "godocdown/kilt/exec_command.go",
    "content": "// This file was AUTOMATICALLY GENERATED by kilt-import (smuggol) from github.com/robertkrimen/kilt\n\npackage kilt\n\nimport (\n\t\"os/exec\"\n)\n\n// ExecCommand\nfunc commandArguments(values ...string) []string {\n\targuments := make([]string, 0, len(values))\n\tfor _, value := range values {\n\t\tif value == \"\\x00\" {\n\t\t\tcontinue\n\t\t}\n\t\targuments = append(arguments, value)\n\t}\n\treturn arguments\n}\n\nfunc (self Kilt) ExecCommand(program string, arguments ...string) *exec.Cmd {\n\treturn ExecCommand(program, arguments...)\n}\n\nfunc ExecCommand(program string, arguments ...string) *exec.Cmd {\n\treturn exec.Command(program, commandArguments(arguments...)...)\n}\n"
  },
  {
    "path": "godocdown/kilt/grave_trim.go",
    "content": "// This file was AUTOMATICALLY GENERATED by kilt-import (smuggol) from github.com/robertkrimen/kilt\n\npackage kilt\n\nimport (\n\t\"unicode\"\n)\n\nfunc (self Kilt) GraveTrim(target string) string {\n\treturn GraveTrim(target)\n}\n\n// GraveTrim\nfunc GraveTrim(target string) string {\n\t// Discard \\r? Go already does this for raw string literals.\n\tend := len(target)\n\n\tlast := 0\n\tindex := 0\n\tfor index = 0; index < end; index++ {\n\t\tchr := rune(target[index])\n\t\tif chr == '\\n' || !unicode.IsSpace(chr) {\n\t\t\tlast = index\n\t\t\tbreak\n\t\t}\n\t}\n\tif index >= end {\n\t\treturn \"\"\n\t}\n\tstart := last\n\tif rune(target[start]) == '\\n' {\n\t\t// Skip the leading newline\n\t\tstart++\n\t}\n\n\tlast = end - 1\n\tfor index = last; index > start; index-- {\n\t\tchr := rune(target[index])\n\t\tif chr == '\\n' || !unicode.IsSpace(chr) {\n\t\t\tlast = index\n\t\t\tbreak\n\t\t}\n\t}\n\tstop := last\n\tresult := target[start : stop+1]\n\treturn result\n}\n"
  },
  {
    "path": "godocdown/kilt/kilt.go",
    "content": "// This file was AUTOMATICALLY GENERATED by kilt-import (smuggol) from github.com/robertkrimen/kilt\n\npackage kilt\n\ntype Kilt struct {\n}\n\nfunc New() *Kilt {\n\treturn &Kilt{}\n}\n"
  },
  {
    "path": "godocdown/kilt/print_defaults.go",
    "content": "// This file was AUTOMATICALLY GENERATED by kilt-import (smuggol) from github.com/robertkrimen/kilt\n\npackage kilt\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\tFlag \"flag\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\n// PrintDefaults\nfunc (self Kilt) PrintDefaults(flag *Flag.FlagSet) {\n\tPrintDefaults(flag)\n}\n\nfunc PrintDefaults(flag *Flag.FlagSet) {\n\tvar into bytes.Buffer\n\tflag.SetOutput(&into)\n\tflag.PrintDefaults()\n\toutfrom := bufio.NewReader(&into)\n\tfor {\n\t\tline, err := outfrom.ReadString('\\n')\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tif strings.HasSuffix(line, \": \\x00\\n\") {\n\t\t\tcontinue\n\t\t}\n\t\tfmt.Fprint(os.Stderr, line)\n\t}\n}\n"
  },
  {
    "path": "godocdown/kilt/sha1.go",
    "content": "// This file was AUTOMATICALLY GENERATED by kilt-import (smuggol) from github.com/robertkrimen/kilt\n\npackage kilt\n\nimport (\n\t\"crypto/sha1\"\n\t\"encoding/hex\"\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n)\n\n// Sha1Path\nfunc (self Kilt) Sha1Path(path ...string) string {\n\treturn Sha1Path(path...)\n}\n\nfunc Sha1Path(path ...string) string {\n\tfile, err := os.Open(filepath.Join(path...))\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\treturn Sha1Of(file)\n}\n\n// Sha1Of\nfunc (self Kilt) Sha1Of(src io.Reader) string {\n\treturn Sha1Of(src)\n}\n\nfunc Sha1Of(src io.Reader) string {\n\thash := sha1.New()\n\t_, err := io.Copy(hash, src)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\treturn hex.EncodeToString(hash.Sum(nil))\n}\n\n// Sha1\nfunc (self Kilt) Sha1(data []byte) string {\n\treturn Sha1(data)\n}\n\nfunc Sha1(data []byte) string {\n\thash := sha1.New()\n\thash.Write(data)\n\treturn hex.EncodeToString(hash.Sum(nil))\n}\n"
  },
  {
    "path": "godocdown/kilt/symlink.go",
    "content": "// This file was AUTOMATICALLY GENERATED by kilt-import (smuggol) from github.com/robertkrimen/kilt\n\npackage kilt\n\nimport (\n\t\"os\"\n)\n\n// Symlink\nfunc (self Kilt) Symlink(oldname, newname string, overwrite bool) error {\n\treturn Symlink(oldname, newname, overwrite)\n}\n\nfunc Symlink(oldname, newname string, overwrite bool) error {\n\terr := os.Symlink(oldname, newname)\n\tif err == nil {\n\t\treturn nil // Success\n\t}\n\tif !os.IsExist(err) {\n\t\treturn err // Failure\n\t}\n\t// Failure, file exists\n\tsymbolic := false\n\t{\n\t\tstat, err := os.Lstat(newname)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tsymbolic = stat.Mode()&os.ModeSymlink != 0\n\t}\n\tif !symbolic {\n\t\treturn err\n\t}\n\tif !overwrite {\n\t\treturn nil\n\t}\n\terr = os.Remove(newname)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn os.Symlink(oldname, newname)\n}\n"
  },
  {
    "path": "godocdown/kilt/write_atomic_file.go",
    "content": "// This file was AUTOMATICALLY GENERATED by kilt-import (smuggol) from github.com/robertkrimen/kilt\n\npackage kilt\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n)\n\n// WriteAtomicFile\nfunc (self Kilt) WriteAtomicFile(filename string, data io.Reader, mode os.FileMode) error {\n\treturn WriteAtomicFile(filename, data, mode)\n}\n\nfunc WriteAtomicFile(filename string, data io.Reader, mode os.FileMode) error {\n\tparent := filepath.Dir(filename)\n\ttmp, err := ioutil.TempDir(parent, \".tmp.\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(parent) >= len(tmp) { // Should never, ever happen\n\t\treturn (fmt.Errorf(\"%s < %s\", tmp, parent))\n\t}\n\tdefer os.RemoveAll(tmp)\n\n\ttmpname := filepath.Join(tmp, filepath.Base(filename))\n\tfile, err := os.OpenFile(tmpname, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, mode)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\t_, err = io.Copy(file, data)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn os.Rename(tmpname, filename)\n}\n"
  },
  {
    "path": "godocdown/kilt.go",
    "content": "// This file was AUTOMATICALLY GENERATED by kilt-import (smuggol) for github.com/robertkrimen/kilt\n\npackage main\n\nimport (\n\tKilt \"github.com/robertkrimen/godocdown/godocdown/kilt\"\n)\n\nvar kilt = Kilt.New()\n"
  },
  {
    "path": "godocdown/main.go",
    "content": "/*\nCommand godocdown generates Go documentation in a GitHub-friendly Markdown format.\n\n    $ go get github.com/robertkrimen/godocdown/godocdown                         \n                                                                                 \n    $ godocdown /path/to/package > README.markdown                               \n                                                                                 \n    # Generate documentation for the package/command in the current directory    \n    $ godocdown > README.markdown                                                \n                                                                                 \n    # Generate standard Markdown                                                 \n    $ godocdown -plain .                                                         \n\nThis program is targeted at providing nice-looking documentation for GitHub. With this in\nmind, it generates GitHub Flavored Markdown (http://github.github.com/github-flavored-markdown/) by\ndefault. This can be changed with the use of the \"plain\" flag to generate standard Markdown.\n\nInstall\n\n    go get github.com/robertkrimen/godocdown/godocdown\n\nExample\n\nhttp://github.com/robertkrimen/godocdown/blob/master/example.markdown\n\nUsage\n\n    -output=\"\"                                                                       \n        Write output to a file instead of stdout                                     \n        Write to stdout with -                                                       \n                                                                                     \n    -template=\"\"                                                                     \n        The template file to use                                                     \n                                                                                     \n    -no-template=false                                                               \n        Disable template processing                                                  \n                                                                                     \n    -plain=false                                                                     \n        Emit standard Markdown, rather than Github Flavored Markdown                 \n                                                                                     \n    -heading=\"TitleCase1Word\"                                                        \n        Heading detection method: 1Word, TitleCase, Title, TitleCase1Word, \"\"        \n        For each line of the package declaration, godocdown attempts to detect if    \n        a heading is present via a pattern match. If a heading is detected,          \n        it prefixes the line with a Markdown heading indicator (typically \"###\").    \n                                                                                     \n        1Word: Only a single word on the entire line                                 \n            [A-Za-z0-9_-]+                                                           \n                                                                                     \n        TitleCase: A line where each word has the first letter capitalized           \n            ([A-Z][A-Za-z0-9_-]\\s*)+                                                 \n                                                                                     \n        Title: A line without punctuation (e.g. a period at the end)                 \n            ([A-Za-z0-9_-]\\s*)+                                                      \n                                                                                     \n        TitleCase1Word: The line matches either the TitleCase or 1Word pattern       \n\nTemplating\n\nIn addition to Markdown rendering, godocdown provides templating via text/template (http://golang.org/pkg/text/template/)\nfor further customization. By putting a file named \".godocdown.template\" (or one from the list below) in the same directory as your\npackage/command, godocdown will know to use the file as a template.\n\n    # text/template\n    .godocdown.markdown\n    .godocdown.md\n    .godocdown.template\n    .godocdown.tmpl\n\nA template file can also be specified with the \"-template\" parameter\n\nAlong with the standard template functionality, the starting data argument has the following interface:\n\n    {{ .Emit }}                                                                                       \n    // Emit the standard documentation (what godocdown would emit without a template)                 \n                                                                                                      \n    {{ .EmitHeader }}                                                                                 \n    // Emit the package name and an import line (if one is present/needed)                            \n                                                                                                      \n    {{ .EmitSynopsis }}                                                                               \n    // Emit the package declaration                                                                   \n                                                                                                      \n    {{ .EmitUsage }}                                                                                  \n    // Emit package usage, which includes a constants section, a variables section,                   \n    // a functions section, and a types section. In addition, each type may have its own constant,    \n    // variable, and/or function/method listing.                                                      \n                                                                                                      \n    {{ if .IsCommand  }} ... {{ end }}                                                                \n    // A boolean indicating whether the given package is a command or a plain package                 \n                                                                                                      \n    {{ .Name }}                                                                                       \n    // The name of the package/command (string)                                                       \n                                                                                                      \n    {{ .ImportPath }}                                                                                 \n    // The import path for the package (string)                                                       \n    // (This field will be the empty string if godocdown is unable to guess it)                       \n*/\npackage main\n\nimport (\n\t\"bytes\"\n\tFlag \"flag\"\n\t\"fmt\"\n\t\"go/build\"\n\t\"go/doc\"\n\t\"go/parser\"\n\t\"go/printer\"\n\t\"go/token\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"strings\"\n\tTemplate \"text/template\"\n\tTime \"time\"\n)\n\nconst (\n\tpunchCardWidth = 80\n\tdebug          = false\n)\n\nvar (\n\tflag            = Flag.NewFlagSet(\"\", Flag.ExitOnError)\n\tflag_signature  = flag.Bool(\"signature\", false, string(0))\n\tflag_plain      = flag.Bool(\"plain\", false, \"Emit standard Markdown, rather than Github Flavored Markdown (the default)\")\n\tflag_heading    = flag.String(\"heading\", \"TitleCase1Word\", \"Heading detection method: 1Word, TitleCase, Title, TitleCase1Word, \\\"\\\"\")\n\tflag_template   = flag.String(\"template\", \"\", \"The template file to use\")\n\tflag_noTemplate = flag.Bool(\"no-template\", false, \"Disable template processing\")\n\tflag_output     = \"\"\n\t_               = func() byte {\n\t\tflag.StringVar(&flag_output, \"output\", flag_output, \"Write output to a file instead of stdout. Write to stdout with -\")\n\t\tflag.StringVar(&flag_output, \"o\", flag_output, string(0))\n\t\treturn 0\n\t}()\n)\n\nvar (\n\tfset *token.FileSet\n\n\tsynopsisHeading1Word_Regexp          = regexp.MustCompile(\"(?m)^([A-Za-z0-9_-]+)$\")\n\tsynopsisHeadingTitleCase_Regexp      = regexp.MustCompile(\"(?m)^((?:[A-Z][A-Za-z0-9_-]*)(?:[ \\t]+[A-Z][A-Za-z0-9_-]*)*)$\")\n\tsynopsisHeadingTitle_Regexp          = regexp.MustCompile(\"(?m)^((?:[A-Za-z0-9_-]+)(?:[ \\t]+[A-Za-z0-9_-]+)*)$\")\n\tsynopsisHeadingTitleCase1Word_Regexp = regexp.MustCompile(\"(?m)^((?:[A-Za-z0-9_-]+)|(?:(?:[A-Z][A-Za-z0-9_-]*)(?:[ \\t]+[A-Z][A-Za-z0-9_-]*)*))$\")\n\n\tstrip_Regexp           = regexp.MustCompile(\"(?m)^\\\\s*// contains filtered or unexported fields\\\\s*\\n\")\n\tindent_Regexp          = regexp.MustCompile(\"(?m)^([^\\\\n])\") // Match at least one character at the start of the line\n\tsynopsisHeading_Regexp = synopsisHeading1Word_Regexp\n\tmatch_7f               = regexp.MustCompile(`(?m)[\\t ]*\\x7f[\\t ]*$`)\n)\n\nvar DefaultStyle = Style{\n\tIncludeImport: true,\n\n\tSynopsisHeader:  \"###\",\n\tSynopsisHeading: synopsisHeadingTitleCase1Word_Regexp,\n\n\tUsageHeader: \"## Usage\\n\",\n\n\tConstantHeader:     \"####\",\n\tVariableHeader:     \"####\",\n\tFunctionHeader:     \"####\",\n\tTypeHeader:         \"####\",\n\tTypeFunctionHeader: \"####\",\n\n\tIncludeSignature: false,\n}\nvar RenderStyle = DefaultStyle\n\nfunc usage() {\n\tfmt.Fprintf(os.Stderr, \"Usage of %s:\\n\", os.Args[0])\n\tkilt.PrintDefaults(flag)\n\texecutable, err := os.Stat(os.Args[0])\n\tif err != nil {\n\t\treturn\n\t}\n\ttime := executable.ModTime()\n\tsince := Time.Since(time)\n\tfmt.Fprintf(os.Stderr, \"---\\n%s (%.2f)\\n\", time.Format(\"2006-01-02 15:04 MST\"), since.Minutes())\n}\n\nfunc init() {\n\tflag.Usage = usage\n}\n\ntype Style struct {\n\tIncludeImport bool\n\n\tSynopsisHeader  string\n\tSynopsisHeading *regexp.Regexp\n\n\tUsageHeader string\n\n\tConstantHeader     string\n\tVariableHeader     string\n\tFunctionHeader     string\n\tTypeHeader         string\n\tTypeFunctionHeader string\n\n\tIncludeSignature bool\n}\n\ntype _document struct {\n\tName       string\n\tpkg        *doc.Package\n\tbuildPkg   *build.Package\n\tIsCommand  bool\n\tImportPath string\n}\n\nfunc takeOut7f(input string) string {\n\treturn match_7f.ReplaceAllString(input, \"\")\n}\n\nfunc _formatIndent(target, indent, preIndent string) string {\n\tvar buffer bytes.Buffer\n\ttoText(&buffer, target, indent, preIndent, punchCardWidth-2*len(indent))\n\treturn buffer.String()\n}\n\nfunc spacer(width int) string {\n\treturn strings.Repeat(\" \", width)\n}\n\nfunc formatIndent(target string) string {\n\treturn _formatIndent(target, spacer(0), spacer(4))\n}\n\nfunc indentCode(target string) string {\n\tif *flag_plain {\n\t\treturn indent(target+\"\\n\", spacer(4))\n\t}\n\treturn fmt.Sprintf(\"```go\\n%s\\n```\", target)\n}\n\nfunc headifySynopsis(target string) string {\n\tdetect := RenderStyle.SynopsisHeading\n\tif detect == nil {\n\t\treturn target\n\t}\n\treturn detect.ReplaceAllStringFunc(target, func(heading string) string {\n\t\treturn fmt.Sprintf(\"%s %s\", RenderStyle.SynopsisHeader, heading)\n\t})\n}\n\nfunc headlineSynopsis(synopsis, header string, scanner *regexp.Regexp) string {\n\treturn scanner.ReplaceAllStringFunc(synopsis, func(headline string) string {\n\t\treturn fmt.Sprintf(\"%s %s\", header, headline)\n\t})\n}\n\nfunc sourceOfNode(target interface{}) string {\n\tvar buffer bytes.Buffer\n\tmode := printer.TabIndent | printer.UseSpaces\n\terr := (&printer.Config{Mode: mode, Tabwidth: 4}).Fprint(&buffer, fset, target)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\treturn strip_Regexp.ReplaceAllString(buffer.String(), \"\")\n}\n\nfunc indent(target string, indent string) string {\n\treturn indent_Regexp.ReplaceAllString(target, indent+\"$1\")\n}\n\nfunc filterText(input string) string {\n\t// Why is this here?\n\t// Normally, godoc will ALWAYS collapse adjacent lines separated only by whitespace.\n\t// However, if you place a (normally invisible) \\x7f character in the documentation,\n\t// this collapse will not happen. Thankfully, Markdown does not need this sort of hack,\n\t// so we remove it.\n\treturn takeOut7f(input)\n}\n\nfunc trimSpace(buffer *bytes.Buffer) {\n\ttmp := bytes.TrimSpace(buffer.Bytes())\n\tbuffer.Reset()\n\tbuffer.Write(tmp)\n}\n\nfunc fromSlash(path string) string {\n\treturn filepath.FromSlash(path)\n}\n\n/*\n    This is how godoc does it:\n\n\t// Determine paths.\n\t//\n\t// If we are passed an operating system path like . or ./foo or /foo/bar or c:\\mysrc,\n\t// we need to map that path somewhere in the fs name space so that routines\n\t// like getPageInfo will see it.  We use the arbitrarily-chosen virtual path \"/target\"\n\t// for this.  That is, if we get passed a directory like the above, we map that\n\t// directory so that getPageInfo sees it as /target.\n\tconst target = \"/target\"\n\tconst cmdPrefix = \"cmd/\"\n\tpath := flag.Arg(0)\n\tvar forceCmd bool\n\tvar abspath, relpath string\n\tif filepath.IsAbs(path) {\n\t\tfs.Bind(target, OS(path), \"/\", bindReplace)\n\t\tabspath = target\n\t} else if build.IsLocalImport(path) {\n\t\tcwd, _ := os.Getwd() // ignore errors\n\t\tpath = filepath.Join(cwd, path)\n\t\tfs.Bind(target, OS(path), \"/\", bindReplace)\n\t\tabspath = target\n\t} else if strings.HasPrefix(path, cmdPrefix) {\n\t\tpath = path[len(cmdPrefix):]\n\t\tforceCmd = true\n\t} else if bp, _ := build.Import(path, \"\", build.FindOnly); bp.Dir != \"\" && bp.ImportPath != \"\" {\n\t\tfs.Bind(target, OS(bp.Dir), \"/\", bindReplace)\n\t\tabspath = target\n\t\trelpath = bp.ImportPath\n\t} else {\n\t\tabspath = pathpkg.Join(pkgHandler.fsRoot, path)\n\t}\n\tif relpath == \"\" {\n\t\trelpath = abspath\n\t}\n*/\nfunc buildImport(target string) (*build.Package, error) {\n\tif filepath.IsAbs(target) {\n\t\treturn build.Default.ImportDir(target, build.FindOnly)\n\t} else if build.IsLocalImport(target) {\n\t\tbase, _ := os.Getwd()\n\t\tpath := filepath.Join(base, target)\n\t\treturn build.Default.ImportDir(path, build.FindOnly)\n\t} else if pkg, _ := build.Default.Import(target, \"\", build.FindOnly); pkg.Dir != \"\" && pkg.ImportPath != \"\" {\n\t\treturn pkg, nil\n\t}\n\tpath, _ := filepath.Abs(target) // Even if there is an error, still try?\n\treturn build.Default.ImportDir(path, build.FindOnly)\n}\n\nfunc guessImportPath(target string) (string, error) {\n\tbuildPkg, err := buildImport(target)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif buildPkg.SrcRoot == \"\" {\n\t\treturn \"\", nil\n\t}\n\treturn buildPkg.ImportPath, nil\n}\n\nfunc loadDocument(target string) (*_document, error) {\n\n\tbuildPkg, err := buildImport(target)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif buildPkg.Dir == \"\" {\n\t\treturn nil, fmt.Errorf(\"Could not find package \\\"%s\\\"\", target)\n\t}\n\n\tpath := buildPkg.Dir\n\n\tfset = token.NewFileSet()\n\tpkgSet, err := parser.ParseDir(fset, path, func(file os.FileInfo) bool {\n\t\tname := file.Name()\n\t\tif name[0] != '.' && strings.HasSuffix(name, \".go\") && !strings.HasSuffix(name, \"_test.go\") {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}, parser.ParseComments)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Could not parse \\\"%s\\\": %v\", path, err)\n\t}\n\n\timportPath := \"\"\n\tif read, err := ioutil.ReadFile(filepath.Join(path, \".godocdown.import\")); err == nil {\n\t\timportPath = strings.TrimSpace(strings.Split(string(read), \"\\n\")[0])\n\t} else {\n\t\timportPath = buildPkg.ImportPath\n\t}\n\n\t{\n\t\tisCommand := false\n\t\tname := \"\"\n\t\tvar pkg *doc.Package\n\n\t\t// Choose the best package for documentation. Either\n\t\t// documentation, main, or whatever the package is.\n\t\tfor _, parsePkg := range pkgSet {\n\t\t\ttmpPkg := doc.New(parsePkg, \".\", 0)\n\t\t\tswitch tmpPkg.Name {\n\t\t\tcase \"main\":\n\t\t\t\tif isCommand || name != \"\" {\n\t\t\t\t\t// We've already seen \"package documentation\"\n\t\t\t\t\t// (or something else), so favor that over main.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfallthrough\n\t\t\tcase \"documentation\":\n\t\t\t\t// We're a command, this package/file contains the documentation\n\t\t\t\t// path is used to get the containing directory in the case of\n\t\t\t\t// command documentation\n\t\t\t\tpath, err := filepath.Abs(path)\n\t\t\t\tif err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t}\n\t\t\t\t_, name = filepath.Split(path)\n\t\t\t\tisCommand = true\n\t\t\t\tpkg = tmpPkg\n\t\t\tdefault:\n\t\t\t\t// Just a regular package\n\t\t\t\tname = tmpPkg.Name\n\t\t\t\tpkg = tmpPkg\n\t\t\t}\n\t\t}\n\n\t\tif pkg != nil {\n\t\t\treturn &_document{\n\t\t\t\tName:       name,\n\t\t\t\tpkg:        pkg,\n\t\t\t\tbuildPkg:   buildPkg,\n\t\t\t\tIsCommand:  isCommand,\n\t\t\t\tImportPath: importPath,\n\t\t\t}, nil\n\t\t}\n\t}\n\n\treturn nil, nil\n}\n\nfunc emitString(fn func(*bytes.Buffer)) string {\n\tvar buffer bytes.Buffer\n\tfn(&buffer)\n\ttrimSpace(&buffer)\n\treturn buffer.String()\n}\n\n// Emit\nfunc (self *_document) Emit() string {\n\treturn emitString(func(buffer *bytes.Buffer) {\n\t\tself.EmitTo(buffer)\n\t})\n}\n\nfunc (self *_document) EmitTo(buffer *bytes.Buffer) {\n\n\t// Header\n\tself.EmitHeaderTo(buffer)\n\n\t// Synopsis\n\tself.EmitSynopsisTo(buffer)\n\n\t// Usage\n\tif !self.IsCommand {\n\t\tself.EmitUsageTo(buffer)\n\t}\n\n\ttrimSpace(buffer)\n}\n\n// Signature\nfunc (self *_document) EmitSignature() string {\n\treturn emitString(func(buffer *bytes.Buffer) {\n\t\tself.EmitSignatureTo(buffer)\n\t})\n}\n\nfunc (self *_document) EmitSignatureTo(buffer *bytes.Buffer) {\n\n\trenderSignatureTo(buffer)\n\n\ttrimSpace(buffer)\n}\n\n// Header\nfunc (self *_document) EmitHeader() string {\n\treturn emitString(func(buffer *bytes.Buffer) {\n\t\tself.EmitHeaderTo(buffer)\n\t})\n}\n\nfunc (self *_document) EmitHeaderTo(buffer *bytes.Buffer) {\n\trenderHeaderTo(buffer, self)\n}\n\n// Synopsis\nfunc (self *_document) EmitSynopsis() string {\n\treturn emitString(func(buffer *bytes.Buffer) {\n\t\tself.EmitSynopsisTo(buffer)\n\t})\n}\n\nfunc (self *_document) EmitSynopsisTo(buffer *bytes.Buffer) {\n\trenderSynopsisTo(buffer, self)\n}\n\n// Usage\nfunc (self *_document) EmitUsage() string {\n\treturn emitString(func(buffer *bytes.Buffer) {\n\t\tself.EmitUsageTo(buffer)\n\t})\n}\n\nfunc (self *_document) EmitUsageTo(buffer *bytes.Buffer) {\n\trenderUsageTo(buffer, self)\n}\n\nvar templateNameList = strings.Fields(`\n\t.godocdown.markdown\n\t.godocdown.md\n\t.godocdown.template\n\t.godocdown.tmpl\n`)\n\nfunc findTemplate(path string) string {\n\n\tfor _, templateName := range templateNameList {\n\t\ttemplatePath := filepath.Join(path, templateName)\n\t\t_, err := os.Stat(templatePath)\n\t\tif err != nil {\n\t\t\tif os.IsExist(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcontinue // Other error reporting?\n\t\t}\n\t\treturn templatePath\n\t}\n\treturn \"\" // Nothing found\n}\n\nfunc loadTemplate(document *_document) *Template.Template {\n\tif *flag_noTemplate {\n\t\treturn nil\n\t}\n\n\ttemplatePath := *flag_template\n\tif templatePath == \"\" {\n\t\ttemplatePath = findTemplate(document.buildPkg.Dir)\n\t}\n\n\tif templatePath == \"\" {\n\t\treturn nil\n\t}\n\n\ttemplate := Template.New(\"\").Funcs(Template.FuncMap{})\n\ttemplate, err := template.ParseFiles(templatePath)\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Error parsing template \\\"%s\\\": %v\", templatePath, err)\n\t\tos.Exit(1)\n\t}\n\treturn template\n}\n\nfunc main() {\n\tflag.Parse(os.Args[1:])\n\ttarget := flag.Arg(0)\n\tfallbackUsage := false\n\tif target == \"\" {\n\t\tfallbackUsage = true\n\t\ttarget = \".\"\n\t}\n\n\tRenderStyle.IncludeSignature = *flag_signature\n\n\tswitch *flag_heading {\n\tcase \"1Word\":\n\t\tRenderStyle.SynopsisHeading = synopsisHeading1Word_Regexp\n\tcase \"TitleCase\":\n\t\tRenderStyle.SynopsisHeading = synopsisHeadingTitleCase_Regexp\n\tcase \"Title\":\n\t\tRenderStyle.SynopsisHeading = synopsisHeadingTitle_Regexp\n\tcase \"TitleCase1Word\":\n\t\tRenderStyle.SynopsisHeading = synopsisHeadingTitleCase1Word_Regexp\n\tcase \"\", \"-\":\n\t\tRenderStyle.SynopsisHeading = nil\n\t}\n\n\tdocument, err := loadDocument(target)\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"%s\\n\", err)\n\t}\n\tif document == nil {\n\t\t// Nothing found.\n\t\tif fallbackUsage {\n\t\t\tusage()\n\t\t\tos.Exit(2)\n\t\t} else {\n\t\t\tfmt.Fprintf(os.Stderr, \"Could not find package: %s\\n\", target)\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\n\ttemplate := loadTemplate(document)\n\n\tvar buffer bytes.Buffer\n\tif template == nil {\n\t\tdocument.EmitTo(&buffer)\n\t\tdocument.EmitSignatureTo(&buffer)\n\t} else {\n\t\terr := template.Templates()[0].Execute(&buffer, document)\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Error running template: %v\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tdocument.EmitSignatureTo(&buffer)\n\t}\n\n\tif debug {\n\t\t// Skip printing if we're debugging\n\t\treturn\n\t}\n\n\tdocumentation := buffer.String()\n\tdocumentation = strings.TrimSpace(documentation)\n\tif flag_output == \"\" || flag_output == \"-\" {\n\t\tfmt.Println(documentation)\n\t} else {\n\t\tfile, err := os.Create(flag_output)\n\t\tif err != nil {\n\t\t}\n\t\tdefer file.Close()\n\t\t_, err = fmt.Fprintln(file, documentation)\n\t}\n}\n"
  },
  {
    "path": "godocdown/main_test.go",
    "content": "package main\n\nimport (\n\t. \"./terst\"\n\t\"bytes\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc canTestImport() bool {\n\thave, err := guessImportPath(\"../example\")\n\tIs(err, nil)\n\treturn len(have) > 0\n}\n\nfunc testImportPath(target, want string) {\n\thave, err := guessImportPath(fromSlash(target))\n\tIs(err, nil)\n\tif have == \"\" {\n\t\t// Probably in a non-standard location, skip the test\n\t\treturn\n\t}\n\tIs(have, want)\n}\n\nfunc TestGuessImportPath(t *testing.T) {\n\tTerst(t)\n\n\ttestImportPath(\"./example\", \"github.com/robertkrimen/godocdown/godocdown/example\")\n\ttestImportPath(\"../example\", \"github.com/robertkrimen/godocdown/example\")\n\tif filepath.Separator == '/' {\n\t\t// This test does not work well on windows\n\t\ttestImportPath(\"/not/in/GOfromSlash\", \"\")\n\t}\n\ttestImportPath(\"in/GOfromSlash\", \"github.com/robertkrimen/godocdown/godocdown/in/GOfromSlash\")\n\ttestImportPath(\".\", \"github.com/robertkrimen/godocdown/godocdown\")\n\ttestImportPath(\"../example/example\", \"github.com/robertkrimen/godocdown/example/example\")\n}\n\nfunc TestFindTemplate(t *testing.T) {\n\tTerst(t)\n\tIs(findTemplate(fromSlash(\".test/godocdown.template\")), fromSlash(\".test/godocdown.template/.godocdown.template\"))\n\tIs(findTemplate(fromSlash(\".test/godocdown.tmpl\")), fromSlash(\".test/godocdown.tmpl/.godocdown.tmpl\"))\n\tIs(findTemplate(fromSlash(\".test/godocdown.md\")), fromSlash(\".test/godocdown.md/.godocdown.md\"))\n\tIs(findTemplate(fromSlash(\".test/godocdown.markdown\")), fromSlash(\".test/godocdown.markdown/.godocdown.markdown\"))\n}\n\nfunc TestIndent(t *testing.T) {\n\tTerst(t)\n\n\tIs(indent(\"1\\n  2\\n\\n  3\\n  4\\n\", \"  \"), \"  1\\n    2\\n\\n    3\\n    4\\n\")\n}\n\nfunc TestHeadlineSynopsis(t *testing.T) {\n\tTerst(t)\n\n\tsynopsis := `\nHeadline\nThe previous line is a single word.\n\na Title Is Without punctuation\n\n\tIn this mode, a title can be something without punctuation\n\nAlso do not title something with a space at the end \n\nOnly Title Casing Is Allowed Here\n\nWhat it says on the tin above.\n\n1word\n\nA title with a-dash\n\t`\n\tis := func(scanner *regexp.Regexp, want string) {\n\t\thave := headlineSynopsis(synopsis, \"#\", scanner)\n\t\tIs(strings.TrimSpace(have), strings.TrimSpace(want))\n\t}\n\n\tis(synopsisHeading1Word_Regexp, `\n# Headline\nThe previous line is a single word.\n\na Title Is Without punctuation\n\n\tIn this mode, a title can be something without punctuation\n\nAlso do not title something with a space at the end \n\nOnly Title Casing Is Allowed Here\n\nWhat it says on the tin above.\n\n# 1word\n\nA title with a-dash\n\t`)\n\n\tis(synopsisHeadingTitleCase_Regexp, `\n# Headline\nThe previous line is a single word.\n\na Title Is Without punctuation\n\n\tIn this mode, a title can be something without punctuation\n\nAlso do not title something with a space at the end \n\n# Only Title Casing Is Allowed Here\n\nWhat it says on the tin above.\n\n1word\n\nA title with a-dash\n\t`)\n\n\tis(synopsisHeadingTitle_Regexp, `\n# Headline\nThe previous line is a single word.\n\n# a Title Is Without punctuation\n\n\tIn this mode, a title can be something without punctuation\n\nAlso do not title something with a space at the end \n\n# Only Title Casing Is Allowed Here\n\nWhat it says on the tin above.\n\n# 1word\n\n# A title with a-dash\n\t`)\n\n\tis(synopsisHeadingTitleCase1Word_Regexp, `\n# Headline\nThe previous line is a single word.\n\na Title Is Without punctuation\n\n\tIn this mode, a title can be something without punctuation\n\nAlso do not title something with a space at the end \n\n# Only Title Casing Is Allowed Here\n\nWhat it says on the tin above.\n\n# 1word\n\nA title with a-dash\n\t`)\n}\n\nfunc Test(t *testing.T) {\n\tTerst(t)\n\n\tdocument, err := loadDocument(\"../example\")\n\tif err != nil {\n\t\tIs(err.Error(), \"\")\n\t\treturn\n\t}\n\tif document == nil {\n\t\tIs(\"200\", \"404\") // Heh\n\t\treturn\n\t}\n\n\tbuffer := bytes.NewBuffer([]byte{})\n\tis := func(want string) {\n\t\tIs(strings.TrimSpace(buffer.String()), strings.TrimSpace(want))\n\t\tbuffer.Reset()\n\t}\n\n\trenderHeaderTo(buffer, document)\n\tif canTestImport() {\n\t\tis(\"# example\\n--\\n    import \\\"github.com/robertkrimen/godocdown/example\\\"\")\n\t} else {\n\t\tis(\"# example\\n--\")\n\t}\n\n\tRenderStyle.IncludeImport = false\n\trenderHeaderTo(buffer, document)\n\tis(`\n# example\n--\n\t`)\n\n\trenderSynopsisTo(buffer, document)\n\tis(`\nPackage example is an example package with documentation\n\n    // Here is some code\n    func example() {\n    \tabc := 1 + 1\n    }()\n\n### Installation\n\n    # This is how to install it:\n    $ curl http://example.com\n    $ tar xf example.tar.gz -C .\n    $ ./example &\n\t`)\n\n\tRenderStyle.IncludeSignature = true\n\trenderSignatureTo(buffer)\n\tis(`\n--\n**godocdown** http://github.com/robertkrimen/godocdown\n\t`)\n\n\trenderSignatureTo(buffer)\n\tIs(buffer.String(), \"\\n\\n--\\n**godocdown** http://github.com/robertkrimen/godocdown\\n\")\n}\n\nfunc Test_issue3(t *testing.T) {\n\tTerst(t)\n\n\tdocument, err := loadDocument(filepath.Join(\".test\", \"issue3\"))\n\tIs(err, nil)\n\tIsNot(document, nil)\n\n\tbuffer := bytes.NewBuffer([]byte{})\n\tdocument.EmitTo(buffer)\n\tIs(strings.TrimSpace(buffer.String()), strings.TrimSpace(`\n# issue3\n--\nDocumentation for package issue3\n\nNothing happens.\n\n    Some code happens.\n\n## Usage\n\n#### func  Test\n\n`+\"```go\\nfunc Test()\\n```\"+`\nDocumentation for func Test()\n\nSomething happens.\n\n    Some code happens.\n    `))\n}\n"
  },
  {
    "path": "godocdown/render.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\t\"go/doc\"\n\t\"io\"\n)\n\nfunc renderConstantSectionTo(writer io.Writer, list []*doc.Value) {\n\tfor _, entry := range list {\n\t\tfmt.Fprintf(writer, \"%s\\n%s\\n\", indentCode(sourceOfNode(entry.Decl)), formatIndent(filterText(entry.Doc)))\n\t}\n}\n\nfunc renderVariableSectionTo(writer io.Writer, list []*doc.Value) {\n\tfor _, entry := range list {\n\t\tfmt.Fprintf(writer, \"%s\\n%s\\n\", indentCode(sourceOfNode(entry.Decl)), formatIndent(filterText(entry.Doc)))\n\t}\n}\n\nfunc renderFunctionSectionTo(writer io.Writer, list []*doc.Func, inTypeSection bool) {\n\n\theader := RenderStyle.FunctionHeader\n\tif inTypeSection {\n\t\theader = RenderStyle.TypeFunctionHeader\n\t}\n\n\tfor _, entry := range list {\n\t\treceiver := \" \"\n\t\tif entry.Recv != \"\" {\n\t\t\treceiver = fmt.Sprintf(\"(%s) \", entry.Recv)\n\t\t}\n\t\tfmt.Fprintf(writer, \"%s func %s%s\\n\\n%s\\n%s\\n\", header, receiver, entry.Name, indentCode(sourceOfNode(entry.Decl)), formatIndent(filterText(entry.Doc)))\n\t}\n}\n\nfunc renderTypeSectionTo(writer io.Writer, list []*doc.Type) {\n\n\theader := RenderStyle.TypeHeader\n\n\tfor _, entry := range list {\n\t\tfmt.Fprintf(writer, \"%s type %s\\n\\n%s\\n\\n%s\\n\", header, entry.Name, indentCode(sourceOfNode(entry.Decl)), formatIndent(filterText(entry.Doc)))\n\t\trenderConstantSectionTo(writer, entry.Consts)\n\t\trenderVariableSectionTo(writer, entry.Vars)\n\t\trenderFunctionSectionTo(writer, entry.Funcs, true)\n\t\trenderFunctionSectionTo(writer, entry.Methods, true)\n\t}\n}\n\nfunc renderHeaderTo(writer io.Writer, document *_document) {\n\tfmt.Fprintf(writer, \"# %s\\n--\\n\", document.Name)\n\n\tif !document.IsCommand {\n\t\t// Import\n\t\tif RenderStyle.IncludeImport {\n\t\t\tif document.ImportPath != \"\" {\n\t\t\t\tfmt.Fprintf(writer, spacer(4)+\"import \\\"%s\\\"\\n\\n\", document.ImportPath)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc renderSynopsisTo(writer io.Writer, document *_document) {\n\tfmt.Fprintf(writer, \"%s\\n\", headifySynopsis(formatIndent(filterText(document.pkg.Doc))))\n}\n\nfunc renderUsageTo(writer io.Writer, document *_document) {\n\t// Usage\n\tfmt.Fprintf(writer, \"%s\\n\", RenderStyle.UsageHeader)\n\n\t// Constant Section\n\trenderConstantSectionTo(writer, document.pkg.Consts)\n\n\t// Variable Section\n\trenderVariableSectionTo(writer, document.pkg.Vars)\n\n\t// Function Section\n\trenderFunctionSectionTo(writer, document.pkg.Funcs, false)\n\n\t// Type Section\n\trenderTypeSectionTo(writer, document.pkg.Types)\n}\n\nfunc renderSignatureTo(writer io.Writer) {\n\tif RenderStyle.IncludeSignature {\n\t\tfmt.Fprintf(writer, \"\\n\\n--\\n**godocdown** http://github.com/robertkrimen/godocdown\\n\")\n\t}\n}\n"
  },
  {
    "path": "godocdown/terst/terst.go",
    "content": "// This file was AUTOMATICALLY GENERATED by terst-import from github.com/robertkrimen/terst\n\n/* \nPackage terst is a terse (terst = test + terse), easy-to-use testing library for Go.\n\nterst is compatible with (and works via) the standard testing package: http://golang.org/pkg/testing\n\n\timport (\n\t\t\"testing\"\n\t\t. \"github.com/robertkrimen/terst\"\n\t)\n\n\tfunc Test(t *testing.T) {\n\t\tTerst(t) // Associate terst methods with t (the current testing.T)\n\n\t\tIs(getApple(), \"apple\") // Pass\n\t\tIs(getOrange(), \"orange\") // Fail: emits nice-looking diagnostic \n\n\t\tCompare(1, \">\", 0) // Pass\n\t\tCompare(1, \"==\", 1.0) // Pass\n\t}\n\n\tfunc getApple() string {\n\t\treturn \"apple\"\n\t}\n\n\tfunc getOrange() string {\n\t\treturn \"apple\" // Intentional mistake\n\t}\n\nAt the top of your testing function, call Terst(), passing the testing.T you receive as the first argument:\n\n\tfunc TestExample(t *testing.T) {\n\t\tTerst(t)\n\t\t...\n\t}\n\nAfter you initialize with the given *testing.T, you can use the following to test:\n\n\tIs\n\tIsNot\n\tEqual\n\tUnequal\n\tIsTrue\n\tIsFalse\n\tLike\n\tUnlike\n\tCompare\n\nEach of the methods above can take an additional (optional) argument,\nwhich is a string describing the test. If the test fails, this\ndescription will be included with the test output For example:\n\n\tIs(2 + 2, float32(5), \"This result is Doubleplusgood\")\n\n\t--- FAIL: Test (0.00 seconds)\n\t\ttest.go:17: This result is Doubleplusgood\n\t\t\tFailed test (Is)\n\t\t\t     got: 4 (int)\n\t\t\texpected: 5 (float32)\n\nFuture\n\n\t- Add Catch() for testing panic()\n\t- Add Same() for testing via .DeepEqual && == (without panicking?)\n\t- Add StrictCompare to use {}= scoping\n\t- Add BigCompare for easier math/big.Int testing?\n\t- Support the complex type in Compare()\n\t- Equality test for NaN?\n\t- Better syntax for At*\n\t- Need IsType/TypeIs\n\n*/\npackage terst\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n\t\"os\"\n\t\"reflect\"\n\t\"regexp\"\n\t\"runtime\"\n\t\"strings\"\n\t\"testing\"\n\t\"unsafe\"\n)\n\nfunc (self *Tester) hadResult(result bool, test *test, onFail func()) bool {\n\tif self.selfTesting {\n\t\texpect := true\n\t\tif self.failIsPassing {\n\t\t\texpect = false\n\t\t}\n\t\tif expect != result {\n\t\t\tself.Log(fmt.Sprintf(\"Expect %v but got %v (%v) (%v) (%v)\\n\", expect, result, test.kind, test.have, test.want))\n\t\t\tonFail()\n\t\t\tself._fail()\n\t\t}\n\t\treturn result\n\t}\n\tif !result {\n\t\tonFail()\n\t\tself._fail()\n\t}\n\treturn result\n}\n\n// IsTrue is DEPRECATED by:\n//\n//      Is(..., true)\n//\nfunc IsTrue(have bool, description ...interface{}) bool {\n\treturn terstTester().IsTrue(have, description...)\n}\n\n// IsTrue is DEPRECATED by:\n//\n//      Is(..., true)\n//\nfunc (self *Tester) IsTrue(have bool, description ...interface{}) bool {\n\treturn self.trueOrFalse(true, have, description...)\n}\n\n// IsFalse is DEPRECATED by:\n//\n//      Is(..., false)\n//\nfunc IsFalse(have bool, description ...interface{}) bool {\n\treturn terstTester().IsFalse(have, description...)\n}\n\n// IsFalse is DEPRECATED by:\n//\n//      Is(..., false)\n//\nfunc (self *Tester) IsFalse(have bool, description ...interface{}) bool {\n\treturn self.trueOrFalse(false, have, description...)\n}\n\nfunc (self *Tester) trueOrFalse(want bool, have bool, description ...interface{}) bool {\n\tkind := \"IsTrue\"\n\tif want == false {\n\t\tkind = \"IsFalse\"\n\t}\n\ttest := newTest(kind, have, want, description)\n\tdidPass := have == want\n\treturn self.hadResult(didPass, test, func() {\n\t\tself.Log(self.failMessageForIsTrue(test))\n\t})\n}\n\n// Fail will fail immediately, reporting a test failure with the (optional) description\nfunc Fail(description ...interface{}) bool {\n\treturn terstTester().Fail(description...)\n}\n\n// Fail will fail immediately, reporting a test failure with the (optional) description\nfunc (self *Tester) Fail(description ...interface{}) bool {\n\treturn self.fail(description...)\n}\n\nfunc (self *Tester) fail(description ...interface{}) bool {\n\tkind := \"Fail\"\n\ttest := newTest(kind, false, false, description)\n\tdidPass := false\n\treturn self.hadResult(didPass, test, func() {\n\t\tself.Log(self.failMessageForFail(test))\n\t})\n}\n\n// FailNow will fail immediately, triggering testing.FailNow() and optionally reporting a test failure with description\nfunc FailNow(description ...interface{}) bool {\n\treturn terstTester().FailNow(description...)\n}\n\n// FailNow will fail immediately, triggering testing.FailNow() and optionally reporting a test failure with description\nfunc (self *Tester) FailNow(description ...interface{}) bool {\n\treturn self.failNow(description...)\n}\n\nfunc (self *Tester) failNow(description ...interface{}) bool {\n\tif len(description) > 0 {\n\t\tkind := \"FailNow\"\n\t\ttest := newTest(kind, false, false, description)\n\t\tdidPass := false\n\t\tself.hadResult(didPass, test, func() {\n\t\t\tself.Log(self.failMessageForFail(test))\n\t\t})\n\t}\n\tself.TestingT.FailNow()\n\treturn false\n}\n\n// Equal tests have against want via ==:\n//\n//\t\tEqual(have, want) // Pass if have == want\n//\n// No special coercion or type inspection is done.\n//\n// If the type is incomparable (e.g. type mismatch) this will panic.\nfunc Equal(have, want interface{}, description ...interface{}) bool {\n\treturn terstTester().Equal(have, want, description...)\n}\n\nfunc (self *Tester) Equal(have, want interface{}, description ...interface{}) bool {\n\treturn self.equal(have, want, description...)\n}\n\nfunc (self *Tester) equal(have, want interface{}, description ...interface{}) bool {\n\ttest := newTest(\"==\", have, want, description)\n\tdidPass := have == want\n\treturn self.hadResult(didPass, test, func() {\n\t\tself.Log(self.failMessageForEqual(test))\n\t})\n}\n\n// Unequal tests have against want via !=:\n//\n//\t\tUnequal(have, want) // Pass if have != want\n//\n// No special coercion or type inspection is done.\n//\n// If the type is incomparable (e.g. type mismatch) this will panic.\nfunc Unequal(have, want interface{}, description ...interface{}) bool {\n\treturn terstTester().Unequal(have, want, description...)\n}\n\nfunc (self *Tester) Unequal(have, want interface{}, description ...interface{}) bool {\n\treturn self.unequal(have, want, description...)\n}\n\nfunc (self *Tester) unequal(have, want interface{}, description ...interface{}) bool {\n\ttest := newTest(\"!=\", have, want, description)\n\tdidPass := have != want\n\treturn self.hadResult(didPass, test, func() {\n\t\tself.Log(self.failMessageForIs(test))\n\t})\n}\n\n// Is tests <have> against <want> in different ways, depending on the\n// type of <want>.\n//\n// If <want> is a string, then it will first convert\n// <have> to a string before doing the comparison:\n//\n//\t\tIs(fmt.Sprintf(\"%v\", have), want) // Pass if have == want\n//\n// Otherwise, Is is a shortcut for:\n//\n//\t\tCompare(have, \"==\", want)\n//\n// If <want> is a slice, struct, or similar, Is will perform a reflect.DeepEqual() comparison.\nfunc Is(have, want interface{}, description ...interface{}) bool {\n\treturn terstTester().Is(have, want, description...)\n}\n\n// TODO \"slice, struct, or similar\" What is similar?\n\nfunc (self *Tester) Is(have, want interface{}, description ...interface{}) bool {\n\treturn self.isOrIsNot(true, have, want, description...)\n}\n\n// IsNot tests <have> against <want> in different ways, depending on the\n// type of <want>.\n//\n// If <want> is a string, then it will first convert\n// <have> to a string before doing the comparison:\n//\n//\t\tIsNot(fmt.Sprintf(\"%v\", have), want) // Pass if have != want\n//\n// Otherwise, Is is a shortcut for:\n//\n//\t\tCompare(have, \"!=\", want)\n//\n// If <want> is a slice, struct, or similar, Is will perform a reflect.DeepEqual() comparison.\nfunc IsNot(have, want interface{}, description ...interface{}) bool {\n\treturn terstTester().IsNot(have, want, description...)\n}\n\n// TODO \"slice, struct, or similar\" What is similar?\n\nfunc (self *Tester) IsNot(have, want interface{}, description ...interface{}) bool {\n\treturn self.isOrIsNot(false, have, want, description...)\n}\n\nfunc (self *Tester) isOrIsNot(wantIs bool, have, want interface{}, description ...interface{}) bool {\n\ttest := newTest(\"Is\", have, want, description)\n\tif !wantIs {\n\t\ttest.kind = \"IsNot\"\n\t}\n\tdidPass := false\n\tswitch want.(type) {\n\tcase string:\n\t\tdidPass = stringValue(have) == want\n\tdefault:\n\t\tdidPass, _ = compare(have, \"{}* ==\", want)\n\t}\n\tif !wantIs {\n\t\tdidPass = !didPass\n\t}\n\treturn self.hadResult(didPass, test, func() {\n\t\tself.Log(self.failMessageForIs(test))\n\t})\n}\n\n// Like tests <have> against <want> in different ways, depending on the\n// type of <want>.\n//\n// If <want> is a string, then it will first convert\n// <have> to a string before doing a regular expression comparison:\n//\n//\t\tLike(fmt.Sprintf(\"%v\", have), want) // Pass if regexp.Match(want, have)\n//\n// Otherwise, Like is a shortcut for:\n//\n//\t\tCompare(have, \"{}~ ==\", want)\n//\n// If <want> is a slice, struct, or similar, Like will perform a reflect.DeepEqual() comparison.\nfunc Like(have, want interface{}, description ...interface{}) bool {\n\treturn terstTester().Like(have, want, description...)\n}\n\nfunc (self *Tester) Like(have, want interface{}, description ...interface{}) bool {\n\treturn self.likeOrUnlike(true, have, want, description...)\n}\n\n// Unlike tests <have> against <want> in different ways, depending on the\n// type of <want>.\n//\n// If <want> is a string, then it will first convert\n// <have> to a string before doing a regular expression comparison:\n//\n//\t\tUnlike(fmt.Sprintf(\"%v\", have), want) // Pass if !regexp.Match(want, have)\n//\n// Otherwise, Unlike is a shortcut for:\n//\n//\t\tCompare(have, \"{}~ !=\", want)\n//\n// If <want> is a slice, struct, or similar, Unlike will perform a reflect.DeepEqual() comparison.\nfunc Unlike(have, want interface{}, description ...interface{}) bool {\n\treturn terstTester().Unlike(have, want, description...)\n}\n\nfunc (self *Tester) Unlike(have, want interface{}, description ...interface{}) bool {\n\treturn self.likeOrUnlike(false, have, want, description...)\n}\n\nfunc (self *Tester) likeOrUnlike(wantLike bool, have, want interface{}, description ...interface{}) bool {\n\ttest := newTest(\"Like\", have, want, description)\n\tif !wantLike {\n\t\ttest.kind = \"Unlike\"\n\t}\n\tdidPass := false\n\tswitch want0 := want.(type) {\n\tcase string:\n\t\thaveString := stringValue(have)\n\t\tdidPass, error := regexp.Match(want0, []byte(haveString))\n\t\tif !wantLike {\n\t\t\tdidPass = !didPass\n\t\t}\n\t\tif error != nil {\n\t\t\tpanic(\"regexp.Match(\" + want0 + \", ...): \" + error.Error())\n\t\t}\n\t\twant = fmt.Sprintf(\"(?:%v)\", want) // Make it look like a regular expression\n\t\treturn self.hadResult(didPass, test, func() {\n\t\t\tself.Log(self.failMessageForMatch(test, stringValue(have), stringValue(want), wantLike))\n\t\t})\n\t}\n\tdidPass, operator := compare(have, \"{}~ ==\", want)\n\tif !wantLike {\n\t\tdidPass = !didPass\n\t}\n\ttest.operator = operator\n\treturn self.hadResult(didPass, test, func() {\n\t\tself.Log(self.failMessageForLike(test, stringValue(have), stringValue(want), wantLike))\n\t})\n}\n\n// Compare will compare <have> to <want> with the given operator. The operator can be one of the following:\n//\n//\t\t  ==\n//\t\t  !=\n//\t\t  <\n//\t\t  <=\n//\t\t  >\n//\t\t  >=\n//\n// Compare is not strict when comparing numeric types,\n// and will make a best effort to promote <have> and <want> to the\n// same type.\n//\n// Compare will promote int and uint to big.Int for testing\n// against each other.\n//\n// Compare will promote int, uint, and float to float64 for\n// float testing.\n//\n// For example:\n//\t\n//\t\tCompare(float32(1.0), \"<\", int8(2)) // A valid test\n//\n//\t\tresult := float32(1.0) < int8(2) // Will not compile because of the type mismatch\n//\nfunc Compare(have interface{}, operator string, want interface{}, description ...interface{}) bool {\n\treturn terstTester().Compare(have, operator, want, description...)\n}\n\nfunc (self *Tester) Compare(have interface{}, operator string, want interface{}, description ...interface{}) bool {\n\treturn self.compare(have, operator, want, description...)\n}\n\nfunc (self *Tester) compare(left interface{}, operatorString string, right interface{}, description ...interface{}) bool {\n\toperatorString = strings.TrimSpace(operatorString)\n\ttest := newTest(\"Compare \"+operatorString, left, right, description)\n\tdidPass, operator := compare(left, operatorString, right)\n\ttest.operator = operator\n\treturn self.hadResult(didPass, test, func() {\n\t\tself.Log(self.failMessageForCompare(test))\n\t})\n}\n\ntype (\n\tcompareScope int\n)\n\nconst (\n\tcompareScopeEqual compareScope = iota\n\tcompareScopeTilde\n\tcompareScopeAsterisk\n)\n\ntype compareOperator struct {\n\tscope      compareScope\n\tcomparison string\n}\n\nvar newCompareOperatorRE *regexp.Regexp = regexp.MustCompile(`^\\s*(?:((?:{}|#)[*~=])\\s+)?(==|!=|<|<=|>|>=)\\s*$`)\n\nfunc newCompareOperator(operatorString string) compareOperator {\n\n\tif operatorString == \"\" {\n\t\treturn compareOperator{compareScopeEqual, \"\"}\n\t}\n\n\tresult := newCompareOperatorRE.FindStringSubmatch(operatorString)\n\tif result == nil {\n\t\tpanic(fmt.Errorf(\"Unable to parse %v into a compareOperator\", operatorString))\n\t}\n\n\tscope := compareScopeAsterisk\n\tswitch result[1] {\n\tcase \"#*\", \"{}*\":\n\t\tscope = compareScopeAsterisk\n\tcase \"#~\", \"{}~\":\n\t\tscope = compareScopeTilde\n\tcase \"#=\", \"{}=\":\n\t\tscope = compareScopeEqual\n\t}\n\n\tcomparison := result[2]\n\n\treturn compareOperator{scope, comparison}\n}\n\nfunc compare(left interface{}, operatorString string, right interface{}) (bool, compareOperator) {\n\tpass := true\n\toperator := newCompareOperator(operatorString)\n\tcomparator := newComparator(left, operator, right)\n\t// FIXME Confusing\n\tswitch operator.comparison {\n\tcase \"==\":\n\t\tpass = comparator.IsEqual()\n\tcase \"!=\":\n\t\tpass = !comparator.IsEqual()\n\tdefault:\n\t\tif comparator.HasOrder() {\n\t\t\tswitch operator.comparison {\n\t\t\tcase \"<\":\n\t\t\t\tpass = comparator.Compare() == -1\n\t\t\tcase \"<=\":\n\t\t\t\tpass = comparator.Compare() <= 0\n\t\t\tcase \">\":\n\t\t\t\tpass = comparator.Compare() == 1\n\t\t\tcase \">=\":\n\t\t\t\tpass = comparator.Compare() >= 0\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"Compare operator (%v) is invalid\", operator.comparison))\n\t\t\t}\n\t\t} else {\n\t\t\tpass = false\n\t\t}\n\t}\n\treturn pass, operator\n}\n\n// Compare / Comparator\n\ntype compareKind int\n\nconst (\n\tkindInterface compareKind = iota\n\tkindInteger\n\tkindUnsignedInteger\n\tkindFloat\n\tkindString\n\tkindBoolean\n)\n\nfunc comparatorValue(value interface{}) (reflect.Value, compareKind) {\n\treflectValue := reflect.ValueOf(value)\n\tkind := kindInterface\n\tswitch value.(type) {\n\tcase int, int8, int16, int32, int64:\n\t\tkind = kindInteger\n\tcase uint, uint8, uint16, uint32, uint64:\n\t\tkind = kindUnsignedInteger\n\tcase float32, float64:\n\t\tkind = kindFloat\n\tcase string:\n\t\tkind = kindString\n\tcase bool:\n\t\tkind = kindBoolean\n\t}\n\treturn reflectValue, kind\n}\n\nfunc toFloat(value reflect.Value) float64 {\n\tswitch result := value.Interface().(type) {\n\tcase int, int8, int16, int32, int64:\n\t\treturn float64(value.Int())\n\tcase uint, uint8, uint16, uint32, uint64:\n\t\treturn float64(value.Uint())\n\tcase float32, float64:\n\t\treturn float64(value.Float())\n\tdefault:\n\t\tpanic(fmt.Errorf(\"toFloat( %v )\", result))\n\t}\n\tpanic(0)\n}\n\nfunc toInteger(value reflect.Value) *big.Int {\n\tswitch result := value.Interface().(type) {\n\tcase int, int8, int16, int32, int64:\n\t\treturn big.NewInt(value.Int())\n\tcase uint, uint8, uint16, uint32, uint64:\n\t\tyield := big.NewInt(0)\n\t\tyield.SetString(fmt.Sprintf(\"%v\", value.Uint()), 10)\n\t\treturn yield\n\tdefault:\n\t\tpanic(fmt.Errorf(\"toInteger( %v )\", result))\n\t}\n\tpanic(0)\n}\n\nfunc toString(value reflect.Value) string {\n\tswitch result := value.Interface().(type) {\n\tcase string:\n\t\treturn result\n\tdefault:\n\t\tpanic(fmt.Errorf(\"toString( %v )\", result))\n\t}\n\tpanic(0)\n}\n\nfunc toBoolean(value reflect.Value) bool {\n\tswitch result := value.Interface().(type) {\n\tcase bool:\n\t\treturn result\n\tdefault:\n\t\tpanic(fmt.Errorf(\"toBoolean( %v )\", result))\n\t}\n\tpanic(0)\n}\n\ntype aComparator interface {\n\tCompare() int\n\tHasOrder() bool\n\tIsEqual() bool\n\tCompareScope() compareScope\n}\n\ntype baseComparator struct {\n\thasOrder bool\n\toperator compareOperator\n}\n\nfunc (self *baseComparator) Compare() int {\n\tpanic(fmt.Errorf(\"Invalid .Compare()\"))\n}\nfunc (self *baseComparator) HasOrder() bool {\n\treturn self.hasOrder\n}\nfunc (self *baseComparator) CompareScope() compareScope {\n\treturn self.operator.scope\n}\nfunc comparatorWithOrder(operator compareOperator) *baseComparator {\n\treturn &baseComparator{true, operator}\n}\nfunc comparatorWithoutOrder(operator compareOperator) *baseComparator {\n\treturn &baseComparator{false, operator}\n}\n\ntype interfaceComparator struct {\n\t*baseComparator\n\tleft  interface{}\n\tright interface{}\n}\n\nfunc (self *interfaceComparator) IsEqual() bool {\n\tif self.CompareScope() != compareScopeEqual {\n\t\treturn reflect.DeepEqual(self.left, self.right)\n\t}\n\treturn self.left == self.right\n}\n\ntype floatComparator struct {\n\t*baseComparator\n\tleft  float64\n\tright float64\n}\n\nfunc (self *floatComparator) Compare() int {\n\tif self.left == self.right {\n\t\treturn 0\n\t} else if self.left < self.right {\n\t\treturn -1\n\t}\n\treturn 1\n}\nfunc (self *floatComparator) IsEqual() bool {\n\treturn self.left == self.right\n}\n\ntype integerComparator struct {\n\t*baseComparator\n\tleft  *big.Int\n\tright *big.Int\n}\n\nfunc (self *integerComparator) Compare() int {\n\treturn self.left.Cmp(self.right)\n}\nfunc (self *integerComparator) IsEqual() bool {\n\treturn 0 == self.left.Cmp(self.right)\n}\n\ntype stringComparator struct {\n\t*baseComparator\n\tleft  string\n\tright string\n}\n\nfunc (self *stringComparator) Compare() int {\n\tif self.left == self.right {\n\t\treturn 0\n\t} else if self.left < self.right {\n\t\treturn -1\n\t}\n\treturn 1\n}\nfunc (self *stringComparator) IsEqual() bool {\n\treturn self.left == self.right\n}\n\ntype booleanComparator struct {\n\t*baseComparator\n\tleft  bool\n\tright bool\n}\n\nfunc (self *booleanComparator) IsEqual() bool {\n\treturn self.left == self.right\n}\n\nfunc newComparator(left interface{}, operator compareOperator, right interface{}) aComparator {\n\tleftValue, _ := comparatorValue(left)\n\trightValue, rightKind := comparatorValue(right)\n\n\t// The simplest comparator is comparing interface{} =? interface{}\n\ttargetKind := kindInterface\n\t// Are left and right of the same kind?\n\t// (reflect.Value.Kind() is different from compareKind)\n\tscopeEqual := leftValue.Kind() == rightValue.Kind()\n\tscopeTilde := false\n\tscopeAsterisk := false\n\tif scopeEqual {\n\t\ttargetKind = rightKind // Since left and right are the same, the targetKind is Integer/Float/String/Boolean\n\t} else {\n\t\t// Examine the prefix of reflect.Value.Kind().String() to see if there is a similarity of \n\t\t// the left value to right value\n\t\tlk := leftValue.Kind().String()\n\t\thasPrefix := func(prefix string) bool {\n\t\t\treturn strings.HasPrefix(lk, prefix)\n\t\t}\n\n\t\tswitch right.(type) {\n\t\tcase float32, float64:\n\t\t\t// Right is float*\n\t\t\tif hasPrefix(\"float\") {\n\t\t\t\t// Left is also float*\n\t\t\t\ttargetKind = kindFloat\n\t\t\t\tscopeTilde = true\n\t\t\t} else if hasPrefix(\"int\") || hasPrefix(\"uint\") {\n\t\t\t\t// Left is a kind of numeric (int* or uint*)\n\t\t\t\ttargetKind = kindFloat\n\t\t\t\tscopeAsterisk = true\n\t\t\t} else {\n\t\t\t\t// Otherwise left is a non-numeric\n\t\t\t}\n\t\tcase uint, uint8, uint16, uint32, uint64:\n\t\t\t// Right is uint*\n\t\t\tif hasPrefix(\"uint\") {\n\t\t\t\t// Left is also uint*\n\t\t\t\ttargetKind = kindInteger\n\t\t\t\tscopeTilde = true\n\t\t\t} else if hasPrefix(\"int\") {\n\t\t\t\t// Left is an int* (a numeric)\n\t\t\t\ttargetKind = kindInteger\n\t\t\t\tscopeAsterisk = true\n\t\t\t} else if hasPrefix(\"float\") {\n\t\t\t\t// Left is an float* (a numeric)\n\t\t\t\ttargetKind = kindFloat\n\t\t\t\tscopeAsterisk = true\n\t\t\t} else {\n\t\t\t\t// Otherwise left is a non-numeric\n\t\t\t}\n\t\tcase int, int8, int16, int32, int64:\n\t\t\t// Right is int*\n\t\t\tif hasPrefix(\"int\") {\n\t\t\t\t// Left is also int*\n\t\t\t\ttargetKind = kindInteger\n\t\t\t\tscopeTilde = true\n\t\t\t} else if hasPrefix(\"uint\") {\n\t\t\t\t// Left is a uint* (a numeric)\n\t\t\t\ttargetKind = kindInteger\n\t\t\t\tscopeAsterisk = true\n\t\t\t} else if hasPrefix(\"float\") {\n\t\t\t\t// Left is an float* (a numeric)\n\t\t\t\ttargetKind = kindFloat\n\t\t\t\tscopeAsterisk = true\n\t\t\t} else {\n\t\t\t\t// Otherwise left is a non-numeric\n\t\t\t}\n\t\tdefault:\n\t\t\t// Right is a non-numeric\n\t\t\t// Can only really compare string to string or boolean to boolean, so\n\t\t\t// we will either have a string/boolean/interfaceComparator\n\t\t}\n\t}\n\n\t/*fmt.Println(\"%v %v %v %v %s %s\", operator.scope, same, sibling, family, leftValue, rightValue)*/\n\t{\n\t\tmismatch := false\n\t\tswitch operator.scope {\n\t\tcase compareScopeEqual:\n\t\t\tmismatch = !scopeEqual\n\t\tcase compareScopeTilde:\n\t\t\tmismatch = !scopeEqual && !scopeTilde\n\t\tcase compareScopeAsterisk:\n\t\t\tmismatch = !scopeEqual && !scopeTilde && !scopeAsterisk\n\t\t}\n\t\tif mismatch {\n\t\t\ttargetKind = kindInterface\n\t\t}\n\t}\n\n\tswitch targetKind {\n\tcase kindFloat:\n\t\treturn &floatComparator{\n\t\t\tcomparatorWithOrder(operator),\n\t\t\ttoFloat(leftValue),\n\t\t\ttoFloat(rightValue),\n\t\t}\n\tcase kindInteger:\n\t\treturn &integerComparator{\n\t\t\tcomparatorWithOrder(operator),\n\t\t\ttoInteger(leftValue),\n\t\t\ttoInteger(rightValue),\n\t\t}\n\tcase kindString:\n\t\treturn &stringComparator{\n\t\t\tcomparatorWithOrder(operator),\n\t\t\ttoString(leftValue),\n\t\t\ttoString(rightValue),\n\t\t}\n\tcase kindBoolean:\n\t\treturn &booleanComparator{\n\t\t\tcomparatorWithoutOrder(operator),\n\t\t\ttoBoolean(leftValue),\n\t\t\ttoBoolean(rightValue),\n\t\t}\n\t}\n\n\t// As a last resort, we can always compare left (interface{}) to right (interface{})\n\treturn &interfaceComparator{\n\t\tcomparatorWithoutOrder(operator),\n\t\tleft,\n\t\tright,\n\t}\n}\n\n// failMessage*\n\nfunc (self *Tester) failMessageForIsTrue(test *test) string {\n\ttest.findFileLineFunction(self)\n\treturn formatMessage(`\n        %s:%d: %s \n           Failed test (%s)\n                  got: %s\n             expected: %s\n    `, test.file, test.line, test.Description(), test.kind, stringValue(test.have), stringValue(test.want))\n}\n\nfunc (self *Tester) failMessageForFail(test *test) string {\n\ttest.findFileLineFunction(self)\n\treturn formatMessage(`\n        %s:%d: %s \n           Failed test (%s)\n    `, test.file, test.line, test.Description(), test.kind)\n}\n\nfunc typeKindString(value interface{}) string {\n\treflectValue := reflect.ValueOf(value)\n\tkind := reflectValue.Kind().String()\n\tresult := fmt.Sprintf(\"%T\", value)\n\tif kind == result {\n\t\tif kind == \"string\" {\n\t\t\treturn \"\"\n\t\t}\n\t\treturn fmt.Sprintf(\" (%T)\", value)\n\t}\n\treturn fmt.Sprintf(\" (%T=%s)\", value, kind)\n}\n\nfunc (self *Tester) failMessageForCompare(test *test) string {\n\ttest.findFileLineFunction(self)\n\treturn formatMessage(`\n        %s:%d: %s \n           Failed test (%s)\n                  %v%s\n                       %s\n                  %v%s\n    `, test.file, test.line, test.Description(), test.kind, test.have, typeKindString(test.have), test.operator.comparison, test.want, typeKindString(test.want))\n}\n\nfunc (self *Tester) failMessageForEqual(test *test) string {\n\treturn self.failMessageForIs(test)\n}\n\nfunc (self *Tester) failMessageForIs(test *test) string {\n\ttest.findFileLineFunction(self)\n\treturn formatMessage(`\n        %s:%d: %v\n           Failed test (%s)\n                  got: %v%s\n             expected: %v%s\n    `, test.file, test.line, test.Description(), test.kind, test.have, typeKindString(test.have), test.want, typeKindString(test.want))\n}\n\nfunc (self *Tester) failMessageForMatch(test *test, have, want string, wantMatch bool) string {\n\ttest.findFileLineFunction(self)\n\texpect := \"  like\"\n\tif !wantMatch {\n\t\texpect = \"unlike\"\n\t}\n\treturn formatMessage(`\n        %s:%d: %s \n           Failed test (%s)\n                  got: %v%s\n               %s: %s\n    `, test.file, test.line, test.Description(), test.kind, have, typeKindString(have), expect, want)\n}\n\nfunc (self *Tester) failMessageForLike(test *test, have, want string, wantLike bool) string {\n\ttest.findFileLineFunction(self)\n\tif !wantLike {\n\t\twant = \"Anything else\"\n\t}\n\treturn formatMessage(`\n        %s:%d: %s \n           Failed test (%s)\n                  got: %v%s\n             expected: %v%s\n    `, test.file, test.line, test.Description(), test.kind, have, typeKindString(have), want, typeKindString(want))\n}\n\n// ...\n\ntype Tester struct {\n\tTestingT *testing.T\n\n\tsanityChecking bool\n\tselfTesting    bool\n\tfailIsPassing  bool\n\n\ttestEntry  uintptr\n\tfocusEntry uintptr\n}\n\nvar _terstTester *Tester = nil\n\nfunc findTestEntry() uintptr {\n\theight := 2\n\tfor {\n\t\tfunctionPC, _, _, ok := runtime.Caller(height)\n\t\tfunction := runtime.FuncForPC(functionPC)\n\t\tfunctionName := function.Name()\n\t\tif !ok {\n\t\t\treturn 0\n\t\t}\n\t\tif index := strings.LastIndex(functionName, \".Test\"); index >= 0 {\n\t\t\t// Assume we have an instance of TestXyzzy in a _test file\n\t\t\treturn function.Entry()\n\t\t}\n\t\theight += 1\n\t}\n\treturn 0\n}\n\n// Focus will focus the entry point of the test to the current method.\n//\n// This is important for test failures in getting feedback on which line was at fault.\n//\n// Consider the following scenario:\n//\n//\t\tfunc testingMethod( ... ) {\n//\t\t\tIs( ..., ... )\n//\t\t}\n//\n//\t\tfunc TestExample(t *testing.T) {\n//\t\t\tTerst(t)\n//\n//\t\t\ttestingMethod( ... )\n//\t\t\ttestingMethod( ... ) // If something in testingMethod fails, this line number will come up\n//\t\t\ttestingMethod( ... )\n//\t\t}\n//\t\n// By default, when a test fails, terst will report the outermost line that led to the failure.\n// Usually this is what you want, but if you need to drill down, you can by inserting a special\n// call at the top of your testing method:\n//\n//\t\tfunc testingMethod( ... ) {\n//\t\t\tTerst().Focus() // Grab the global Tester and tell it to focus on this method\n//\t\t\tIs( ..., ... ) // Now if this test fails, this line number will come up\n//\t\t}\n//\nfunc (self *Tester) Focus() {\n\tpc, _, _, ok := runtime.Caller(1)\n\tif ok {\n\t\tfunction := runtime.FuncForPC(pc)\n\t\tself.focusEntry = function.Entry()\n\t}\n}\n\n//\t\tTerst(*testing.T)\n//\n// Create a new terst Tester and return it.  Associate calls to Is, Compare, Like, etc. with the newly created terst.\n//\n//\t\tTerst()\n//\n// Return the current Tester (if any).\n//\n//\t\tTerst(nil)\n//\n// Clear out the current Tester (if any).\nfunc Terst(terst ...interface{}) *Tester {\n\tif len(terst) == 0 {\n\t\treturn terstTester()\n\t} else {\n\t\tif terst[0] == nil {\n\t\t\t_terstTester = nil\n\t\t\treturn nil\n\t\t}\n\t\t_terstTester = newTester(terst[0].(*testing.T))\n\t\t_terstTester.enableSanityChecking()\n\t\t_terstTester.testEntry = findTestEntry()\n\t\t_terstTester.focusEntry = _terstTester.testEntry\n\t}\n\treturn _terstTester\n}\n\nfunc terstTester() *Tester {\n\tif _terstTester == nil {\n\t\tpanic(\"_terstTester == nil\")\n\t}\n\treturn _terstTester.checkSanity()\n}\n\nfunc newTester(t *testing.T) *Tester {\n\treturn &Tester{\n\t\tTestingT: t,\n\t}\n}\n\nfunc formatMessage(message string, argumentList ...interface{}) string {\n\tmessage = fmt.Sprintf(message, argumentList...)\n\tmessage = strings.TrimLeft(message, \"\\n\")\n\tmessage = strings.TrimRight(message, \" \\n\")\n\treturn message + \"\\n\\n\"\n}\n\n// Log is a utility method that will append the given output to the normal output stream.\nfunc (self *Tester) Log(output string) {\n\toutputValue := reflect.ValueOf(self.TestingT).Elem().FieldByName(\"output\")\n\toutput_ := outputValue.Bytes()\n\toutput_ = append(output_, output...)\n\t*(*[]byte)(unsafe.Pointer(outputValue.UnsafeAddr())) = output_\n}\n\nfunc (self *Tester) _fail() {\n\tself.TestingT.Fail()\n}\n\nfunc (self *Tester) enableSanityChecking() *Tester {\n\tself.sanityChecking = true\n\treturn self\n}\n\nfunc (self *Tester) disableSanityChecking() *Tester {\n\tself.sanityChecking = false\n\treturn self\n}\n\nfunc (self *Tester) enableSelfTesting() *Tester {\n\tself.selfTesting = true\n\treturn self\n}\n\nfunc (self *Tester) disableSelfTesting() *Tester {\n\tself.selfTesting = false\n\treturn self\n}\n\nfunc (self *Tester) failIsPass() *Tester {\n\tself.failIsPassing = true\n\treturn self\n}\n\nfunc (self *Tester) passIsPass() *Tester {\n\tself.failIsPassing = false\n\treturn self\n}\n\nfunc (self *Tester) checkSanity() *Tester {\n\tif self.sanityChecking && self.testEntry != 0 {\n\t\tfoundEntryPoint := findTestEntry()\n\t\tif self.testEntry != foundEntryPoint {\n\t\t\tpanic(fmt.Errorf(\"TestEntry(%v) does not match foundEntry(%v): Did you call Terst when entering a new Test* function?\", self.testEntry, foundEntryPoint))\n\t\t}\n\t}\n\treturn self\n}\n\nfunc (self *Tester) findDepth() int {\n\theight := 1 // Skip us\n\tfor {\n\t\tpc, _, _, ok := runtime.Caller(height)\n\t\tfunction := runtime.FuncForPC(pc)\n\t\tif !ok {\n\t\t\t// Got too close to the sun\n\t\t\tif false {\n\t\t\t\tfor ; height > 0; height-- {\n\t\t\t\t\tpc, _, _, ok := runtime.Caller(height)\n\t\t\t\t\tfmt.Printf(\"[%d %v %v]\", height, pc, ok)\n\t\t\t\t\tif ok {\n\t\t\t\t\t\tfunction := runtime.FuncForPC(pc)\n\t\t\t\t\t\tfmt.Printf(\" => [%s]\", function.Name())\n\t\t\t\t\t}\n\t\t\t\t\tfmt.Printf(\"\\n\")\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 1\n\t\t}\n\t\tfunctionEntry := function.Entry()\n\t\tif functionEntry == self.focusEntry || functionEntry == self.testEntry {\n\t\t\treturn height - 1 // Not the surrounding test function, but within it\n\t\t}\n\t\theight += 1\n\t}\n\treturn 1\n}\n\n// test\n\ntype test struct {\n\tkind        string\n\thave        interface{}\n\twant        interface{}\n\tdescription []interface{}\n\toperator    compareOperator\n\n\tfile       string\n\tline       int\n\tfunctionPC uintptr\n\tfunction   string\n}\n\nfunc newTest(kind string, have, want interface{}, description []interface{}) *test {\n\toperator := newCompareOperator(\"\")\n\treturn &test{\n\t\tkind:        kind,\n\t\thave:        have,\n\t\twant:        want,\n\t\tdescription: description,\n\t\toperator:    operator,\n\t}\n}\n\nfunc (self *test) findFileLineFunction(tester *Tester) {\n\tself.file, self.line, self.functionPC, self.function, _ = atFileLineFunction(tester.findDepth())\n}\n\nfunc (self *test) Description() string {\n\tdescription := \"\"\n\tif len(self.description) > 0 {\n\t\tdescription = fmt.Sprintf(\"%v\", self.description[0])\n\t}\n\treturn description\n}\n\nfunc findPathForFile(file string) string {\n\tterstBase := os.ExpandEnv(\"$TERST_BASE\")\n\tif len(terstBase) > 0 && strings.HasPrefix(file, terstBase) {\n\t\tfile = file[len(terstBase):]\n\t\tif file[0] == '/' || file[0] == '\\\\' {\n\t\t\tfile = file[1:]\n\t\t}\n\t\treturn file\n\t}\n\n\tif index := strings.LastIndex(file, \"/\"); index >= 0 {\n\t\tfile = file[index+1:]\n\t} else if index = strings.LastIndex(file, \"\\\\\"); index >= 0 {\n\t\tfile = file[index+1:]\n\t}\n\n\treturn file\n}\n\nfunc atFileLineFunction(callDepth int) (string, int, uintptr, string, bool) {\n\tpc, file, line, ok := runtime.Caller(callDepth + 1)\n\tfunction := runtime.FuncForPC(pc).Name()\n\tif ok {\n\t\tfile = findPathForFile(file)\n\t\tif index := strings.LastIndex(function, \".Test\"); index >= 0 {\n\t\t\tfunction = function[index+1:]\n\t\t}\n\t} else {\n\t\tpc = 0\n\t\tfile = \"?\"\n\t\tline = 1\n\t}\n\treturn file, line, pc, function, ok\n}\n\n// Conversion\n\nfunc integerValue(value interface{}) int64 {\n\treturn reflect.ValueOf(value).Int()\n}\n\nfunc unsignedIntegerValue(value interface{}) uint64 {\n\treturn reflect.ValueOf(value).Uint()\n}\n\nfunc floatValue(value interface{}) float64 {\n\treturn reflect.ValueOf(value).Float()\n}\n\nfunc stringValue(value interface{}) string {\n\treturn fmt.Sprintf(\"%v\", value)\n}\n"
  },
  {
    "path": "godocdown.go",
    "content": "// Package godocdown is placeholder for the godocdown command\n//\n// This is a placeholder package, the actual command is:\n// http://github.com/robertkrimen/godocdown/godocdown\n//\n//      $ go get http://github.com/robertkrimen/godocdown/godocdown\n//\n//      # Generate documentation, like godoc\n//      $ godocdown .\n//\npackage godocdown\n\nimport (\n\t_ \"github.com/robertkrimen/godocdown/godocdown\"\n)\n"
  }
]