Debian Codegraph @

docs/man/mangen.go

raw symbols SCIP
1 package mainscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/
2
3 import (
4 "bufioscip-go gomod github.com/golang/go/src go1.25.0 bufio/"
5 "flagscip-go gomod github.com/golang/go/src go1.25.0 flag/"
6 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
7 "ioscip-go gomod github.com/golang/go/src go1.25.0 io/"
8 "osscip-go gomod github.com/golang/go/src go1.25.0 os/"
9 "path/filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/"
10 "regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/"
11 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
12 )
13
14 func infofscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/infof().(w ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Writerscip-go gomod github.com/golang/go/src go1.25.0 io/Writer#, format string, a ...interface{}) {
15 if !*verbosescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/verbose. {
16 return
17 }
18 fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintf().(w, format, a...)
19 }
20
21 func warnfscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/warnf().(w ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Writerscip-go gomod github.com/golang/go/src go1.25.0 io/Writer#, format string, a ...interface{}) {
22 fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintf().(w, format, a...)
23 }
24
25 func readManDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/readManDir().() (string, []osscip-go gomod github.com/golang/go/src go1.25.0 os/.DirEntryscip-go gomod github.com/golang/go/src go1.25.0 os/DirEntry#) {
26 rootDirs := []string{
27 "..",
28 "/tmp/docker_run/git-lfs",
29 }
30
31 var err error
32 for _, rootDir := range rootDirs {
33 fs, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.ReadDirscip-go gomod github.com/golang/go/src go1.25.0 os/ReadDir().(filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(rootDir, "docs", "man"))
34 if err == nil {
35 return rootDir, fs
36 }
37 }
38
39 warnfscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/warnf().(osscip-go gomod github.com/golang/go/src go1.25.0 os/.Stderrscip-go gomod github.com/golang/go/src go1.25.0 os/Stderr., "Failed to open man dir: %v\n", err)
40 osscip-go gomod github.com/golang/go/src go1.25.0 os/.Exitscip-go gomod github.com/golang/go/src go1.25.0 os/Exit().(2)
41 return "", nil
42 }
43
44 func titleizeXrefscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/titleizeXref().(s string) string {
45 return stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Replacescip-go gomod github.com/golang/go/src go1.25.0 strings/Replace().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ToTitlescip-go gomod github.com/golang/go/src go1.25.0 strings/ToTitle().(s[1:2])+s[2:], "_", " ", -1)
46 }
47
48 var (
49 verbosescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/verbose. = flagscip-go gomod github.com/golang/go/src go1.25.0 flag/.Boolscip-go gomod github.com/golang/go/src go1.25.0 flag/Bool().("verbose", false, "Show verbose output.")
50 )
51
52 // Reads all .adoc files & and converts them to string literals
53 // triggered by "go generate" comment
54 // Literals are inserted into a map using an init function, this means
55 // that there are no compilation errors if 'go generate' hasn't been run, just
56 // blank man files.
57 func mainscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/main().() {
58 flagscip-go gomod github.com/golang/go/src go1.25.0 flag/.Parsescip-go gomod github.com/golang/go/src go1.25.0 flag/Parse().()
59
60 infofscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/infof().(osscip-go gomod github.com/golang/go/src go1.25.0 os/.Stderrscip-go gomod github.com/golang/go/src go1.25.0 os/Stderr., "Converting man pages into code...\n")
61 rootDir, fs := readManDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/readManDir().()
62 manDir := filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(rootDir, "docs", "man")
63 out, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Createscip-go gomod github.com/golang/go/src go1.25.0 os/Create().(filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(rootDir, "commands", "mancontent_gen.go"))
64 if err != nil {
65 warnfscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/warnf().(osscip-go gomod github.com/golang/go/src go1.25.0 os/.Stderrscip-go gomod github.com/golang/go/src go1.25.0 os/Stderr., "Failed to create go file: %v\n", err)
66 osscip-go gomod github.com/golang/go/src go1.25.0 os/.Exitscip-go gomod github.com/golang/go/src go1.25.0 os/Exit().(2)
67 }
68 out.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteString().("package commands\n\nfunc init() {\n")
69 out.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteString().("\t// THIS FILE IS GENERATED, DO NOT EDIT\n")
70 out.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteString().("\t// Use 'go generate ./commands' to update\n")
71 fileregex := regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.0 regexp/MustCompile().(`git-lfs(?:-([A-Za-z\-]+))?.adoc`)
72 headerregex := regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.0 regexp/MustCompile().(`^(===?)\s+([A-Za-z0-9 -]+)`)
73 // cross-references
74 linkregex := regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.0 regexp/MustCompile().(`<<([^,>]+)(?:,([^>]+))?>>`)
75 // man links
76 manlinkregex := regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.0 regexp/MustCompile().(`(git)(?:-(lfs))?-([a-z\-]+)\(\d\)`)
77 // source blocks
78 sourceblockregex := regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.0 regexp/MustCompile().(`\[source(,.*)?\]`)
79 // synopsis source block quotes substitution group syntax
80 synopsisQuotesRegex := regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.0 regexp/MustCompile().(`[\*_]+`)
81 // anchors
82 anchorregex := regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.0 regexp/MustCompile().(`\[\[(.+)\]\]`)
83 count := 0
84 for _, f := range fs {
85 if match := fileregex.FindStringSubmatchscip-go gomod github.com/golang/go/src go1.25.0 regexp/Regexp#FindStringSubmatch().(f.Namescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/DirEntry#Name().()); match != nil {
86 infofscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/infof().(osscip-go gomod github.com/golang/go/src go1.25.0 os/.Stderrscip-go gomod github.com/golang/go/src go1.25.0 os/Stderr., "%v\n", f.Namescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/DirEntry#Name().())
87 cmd := match[1]
88 if len(cmd) == 0 {
89 // This is git-lfs.1.adoc
90 cmd = "git-lfs"
91 }
92 out.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteString().("\tManPages[\"" + cmd + "\"] = `")
93 contentf, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Openscip-go gomod github.com/golang/go/src go1.25.0 os/Open().(filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(manDir, f.Namescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/DirEntry#Name().()))
94 if err != nil {
95 warnfscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/warnf().(osscip-go gomod github.com/golang/go/src go1.25.0 os/.Stderrscip-go gomod github.com/golang/go/src go1.25.0 os/Stderr., "Failed to open %v: %v\n", f.Namescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/DirEntry#Name().(), err)
96 osscip-go gomod github.com/golang/go/src go1.25.0 os/.Exitscip-go gomod github.com/golang/go/src go1.25.0 os/Exit().(2)
97 }
98 // Process the asciidoc to make it nicer as help text
99 scanner := bufioscip-go gomod github.com/golang/go/src go1.25.0 bufio/.NewScannerscip-go gomod github.com/golang/go/src go1.25.0 bufio/NewScanner().(contentf)
100 firstHeaderDone := false
101 skipNextLineIfBlank := false
102 lastLineWasList := false
103 isSourceBlock := false
104 isSynopsisSourceBlock := false
105 sourceBlockLine := ""
106 scanloop:
107 for scanner.Scanscip-go gomod github.com/golang/go/src go1.25.0 bufio/Scanner#Scan().() {
108 line := scanner.Textscip-go gomod github.com/golang/go/src go1.25.0 bufio/Scanner#Text().()
109 trimmedline := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.25.0 strings/TrimSpace().(line)
110 if skipNextLineIfBlank && len(trimmedline) == 0 {
111 skipNextLineIfBlank = false
112 lastLineWasList = false
113 continue
114 }
115
116 // Special case headers
117 if hmatch := headerregex.FindStringSubmatchscip-go gomod github.com/golang/go/src go1.25.0 regexp/Regexp#FindStringSubmatch().(line); hmatch != nil {
118 if len(hmatch[1]) == 2 {
119 header := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.0 strings/ToLower().(hmatch[2])
120 switch header {
121 case "name":
122 continue
123 case "synopsis":
124 // Ignore this, just go direct to command
125
126 case "description":
127 // Just skip the header & newline
128 skipNextLineIfBlank = true
129 case "options":
130 out.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteString().("Options:" + "\n")
131 case "see also":
132 // don't include any content after this
133 break scanloop
134 default:
135 out.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteString().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ToUpperscip-go gomod github.com/golang/go/src go1.25.0 strings/ToUpper().(header[:1]) + header[1:] + "\n")
136 out.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteString().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("-", len(header)) + "\n")
137 }
138 firstHeaderDone = true
139 } else {
140 out.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteString().(hmatch[2] + "\n")
141 out.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteString().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("~", len(hmatch[2])) + "\n")
142 }
143 lastLineWasList = false
144 continue
145 }
146
147 if lmatches := linkregex.FindAllStringSubmatchscip-go gomod github.com/golang/go/src go1.25.0 regexp/Regexp#FindAllStringSubmatch().(line, -1); lmatches != nil {
148 for _, lmatch := range lmatches {
149 if len(lmatch) > 2 && lmatch[2] != "" {
150 line = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Replacescip-go gomod github.com/golang/go/src go1.25.0 strings/Replace().(line, lmatch[0], `"`+lmatch[2]+`"`, 1)
151 } else {
152 line = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Replacescip-go gomod github.com/golang/go/src go1.25.0 strings/Replace().(line, lmatch[0], `"`+titleizeXrefscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/titleizeXref().(lmatch[1])+`"`, 1)
153 }
154 }
155 }
156 if manmatches := manlinkregex.FindAllStringSubmatchscip-go gomod github.com/golang/go/src go1.25.0 regexp/Regexp#FindAllStringSubmatch().(line, -1); manmatches != nil {
157 for _, manmatch := range manmatches {
158 line = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Replacescip-go gomod github.com/golang/go/src go1.25.0 strings/Replace().(line, manmatch[0], stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.0 strings/Join().(manmatch[1:], " "), 1)
159 }
160 }
161
162 if sourceblockmatches := sourceblockregex.FindStringIndexscip-go gomod github.com/golang/go/src go1.25.0 regexp/Regexp#FindStringIndex().(line); sourceblockmatches != nil {
163 isSourceBlock = true
164 if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Containsscip-go gomod github.com/golang/go/src go1.25.0 strings/Contains().(line, "role=synopsis") {
165 isSynopsisSourceBlock = true
166 }
167 continue
168 }
169
170 if anchormatches := anchorregex.FindStringIndexscip-go gomod github.com/golang/go/src go1.25.0 regexp/Regexp#FindStringIndex().(line); anchormatches != nil {
171 // Skip anchors.
172 continue
173 }
174
175 // Skip content until after first header
176 if !firstHeaderDone {
177 continue
178 }
179 // OK, content here
180
181 // handle source block headers
182 if isSourceBlock {
183 sourceBlockLine = line
184 isSourceBlock = false
185 line = ""
186 continue
187 } else if sourceBlockLine != "" && line == sourceBlockLine {
188 isSynopsisSourceBlock = false
189 line = ""
190 sourceBlockLine = ""
191 }
192
193 // remove characters that asciidoc would render invisible in a text env.
194 for _, invis := range []string{"`", "...."} {
195 line = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Replacescip-go gomod github.com/golang/go/src go1.25.0 strings/Replace().(line, invis, "", -1)
196 }
197 line = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimSuffixscip-go gomod github.com/golang/go/src go1.25.0 strings/TrimSuffix().(line, " +")
198
199 if isSynopsisSourceBlock {
200 line = synopsisQuotesRegex.ReplaceAllStringscip-go gomod github.com/golang/go/src go1.25.0 regexp/Regexp#ReplaceAllString().(line, "")
201 }
202
203 // indent bullets and definition lists
204 if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(line, "*") {
205 lastLineWasList = true
206 } else if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasSuffixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasSuffix().(line, "::") {
207 lastLineWasList = true
208 line = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimSuffixscip-go gomod github.com/golang/go/src go1.25.0 strings/TrimSuffix().(line, ":")
209 } else if lastLineWasList && line == "+" {
210 line = ""
211 } else if lastLineWasList && line == "" {
212 lastLineWasList = false
213 } else if lastLineWasList && !stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(line, " ") {
214 // indent paragraphs under bullets if not already done
215 line = " " + line
216 }
217
218 out.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteString().(line + "\n")
219 }
220 out.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteString().("`\n")
221 contentf.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().()
222 count++
223 }
224 }
225 out.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteString().("}\n")
226 infofscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/docs/man`/infof().(osscip-go gomod github.com/golang/go/src go1.25.0 os/.Stderrscip-go gomod github.com/golang/go/src go1.25.0 os/Stderr., "Successfully processed %d man pages.\n", count)
227
228 }