Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
79284cae
Commit
79284cae
authored
Nov 05, 2009
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofmt'ed src/cmd
R=rsc
http://go/go-review/1024004
parent
07b6becc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
32 deletions
+32
-32
src/cmd/godoc/godoc.go
src/cmd/godoc/godoc.go
+25
-26
src/cmd/godoc/main.go
src/cmd/godoc/main.go
+4
-4
src/cmd/godoc/spec.go
src/cmd/godoc/spec.go
+2
-1
src/cmd/goyacc/doc.go
src/cmd/goyacc/doc.go
+1
-1
No files found.
src/cmd/godoc/godoc.go
View file @
79284cae
...
...
@@ -86,7 +86,7 @@ var (
)
var
fsTree
RWValue
;
// *Directory tree of packages, updated with each sync
var
fsTree
RWValue
// *Directory tree of packages, updated with each sync
func
init
()
{
...
...
@@ -139,9 +139,9 @@ func htmlEscape(s string) string {
// Package directories
type
Directory
struct
{
Path
string
;
// includes Name
Name
string
;
Dirs
[]
*
Directory
;
Path
string
;
// includes Name
Name
string
;
Dirs
[]
*
Directory
;
}
...
...
@@ -153,7 +153,7 @@ func newDirTree(path, name string, depth int) *Directory {
return
&
Directory
{
path
,
name
,
nil
};
}
list
,
_
:=
io
.
ReadDir
(
path
);
// ignore errors
list
,
_
:=
io
.
ReadDir
(
path
);
// ignore errors
// determine number of subdirectories and package files
ndirs
:=
0
;
...
...
@@ -210,7 +210,7 @@ func newDirectory(root string, depth int) *Directory {
// lookup looks for the *Directory for a given path, relative to dir.
func
(
dir
*
Directory
)
lookup
(
path
string
)
*
Directory
{
path
=
pathutil
.
Clean
(
path
);
// no trailing '/'
path
=
pathutil
.
Clean
(
path
);
// no trailing '/'
if
dir
==
nil
||
path
==
""
||
path
==
"."
{
return
dir
;
...
...
@@ -224,7 +224,7 @@ func (dir *Directory) lookup(path string) *Directory {
return
d
;
}
}
return
nil
return
nil
;
}
return
dir
.
lookup
(
dpath
)
.
lookup
(
dname
);
...
...
@@ -404,7 +404,7 @@ func htmlFmt(w io.Writer, x interface{}, format string) {
func
htmlCommentFmt
(
w
io
.
Writer
,
x
interface
{},
format
string
)
{
var
buf
bytes
.
Buffer
;
writeAny
(
&
buf
,
x
,
false
);
doc
.
ToHtml
(
w
,
buf
.
Bytes
());
// does html-escaping
doc
.
ToHtml
(
w
,
buf
.
Bytes
());
// does html-escaping
}
...
...
@@ -416,7 +416,7 @@ func textFmt(w io.Writer, x interface{}, format string) {
// Template formatter for "dir" format.
func
dirFmt
(
w
io
.
Writer
,
x
interface
{},
format
string
)
{
_
=
x
.
(
*
Directory
);
// die quickly if x has the wrong type
_
=
x
.
(
*
Directory
);
// die quickly if x has the wrong type
if
err
:=
dirsHtml
.
Execute
(
x
,
w
);
err
!=
nil
{
log
.
Stderrf
(
"dirsHtml.Execute: %s"
,
err
);
}
...
...
@@ -425,7 +425,7 @@ func dirFmt(w io.Writer, x interface{}, format string) {
func
removePrefix
(
s
,
prefix
string
)
string
{
if
strings
.
HasPrefix
(
s
,
prefix
)
{
return
s
[
len
(
prefix
)
:
len
(
s
)];
return
s
[
len
(
prefix
)
:
len
(
s
)];
}
return
s
;
}
...
...
@@ -471,7 +471,7 @@ var infoClasses = [nKinds]string{
// Template formatter for "infoClass" format.
func
infoClassFmt
(
w
io
.
Writer
,
x
interface
{},
format
string
)
{
fmt
.
Fprintf
(
w
,
infoClasses
[
x
.
(
SpotInfo
)
.
Kind
()]);
// no html escaping needed
fmt
.
Fprintf
(
w
,
infoClasses
[
x
.
(
SpotInfo
)
.
Kind
()]);
// no html escaping needed
}
...
...
@@ -530,12 +530,12 @@ func readTemplate(name string) *template.Template {
var
(
dirsHtml
,
godocHtml
,
packageHtml
,
packageText
,
parseerrorHtml
,
parseerrorText
,
searchHtml
*
template
.
Template
;
godocHtml
,
packageHtml
,
packageText
,
parseerrorHtml
,
parseerrorText
,
searchHtml
*
template
.
Template
;
)
func
readTemplates
()
{
...
...
@@ -694,9 +694,9 @@ type PageInfo struct {
type
httpHandler
struct
{
pattern
string
;
// url pattern; e.g. "/pkg/"
fsRoot
string
;
// file system root to which the pattern is mapped
isPkg
bool
;
// true if this handler serves real package documentation (as opposed to command documentation)
pattern
string
;
// url pattern; e.g. "/pkg/"
fsRoot
string
;
// file system root to which the pattern is mapped
isPkg
bool
;
// true if this handler serves real package documentation (as opposed to command documentation)
}
...
...
@@ -754,14 +754,14 @@ func (h *httpHandler) getPageInfo(path string) PageInfo {
// or command-line mode); compute one level for this page
dir
=
newDirectory
(
dirname
,
1
);
}
return
PageInfo
{
pdoc
,
dir
,
h
.
isPkg
};
}
func
(
h
*
httpHandler
)
ServeHTTP
(
c
*
http
.
Conn
,
r
*
http
.
Request
)
{
path
:=
r
.
Url
.
Path
;
path
=
path
[
len
(
h
.
pattern
)
:
len
(
path
)];
path
=
path
[
len
(
h
.
pattern
)
:
len
(
path
)];
// canonicalize URL path and redirect if necessary
if
canonical
:=
pathutil
.
Clean
(
h
.
pattern
+
path
)
+
"/"
;
r
.
Url
.
Path
!=
canonical
{
...
...
@@ -797,7 +797,7 @@ func (h *httpHandler) ServeHTTP(c *http.Conn, r *http.Request) {
_
,
pkgname
:=
pathutil
.
Split
(
pathutil
.
Clean
(
path
));
title
=
"Command "
+
pkgname
;
default
:
title
=
"Command "
+
info
.
PDoc
.
PackageName
title
=
"Command "
+
info
.
PDoc
.
PackageName
;
}
}
...
...
@@ -850,8 +850,8 @@ func search(c *http.Conn, r *http.Request) {
// Server
var
(
cmdHandler
=
httpHandler
{
"/cmd/"
,
*
cmdroot
,
false
};
pkgHandler
=
httpHandler
{
"/pkg/"
,
*
pkgroot
,
true
};
cmdHandler
=
httpHandler
{
"/cmd/"
,
*
cmdroot
,
false
};
pkgHandler
=
httpHandler
{
"/pkg/"
,
*
pkgroot
,
true
};
)
...
...
@@ -885,4 +885,3 @@ func indexer() {
time
.
Sleep
(
1
*
60e9
);
// try once a minute
}
}
src/cmd/godoc/main.go
View file @
79284cae
...
...
@@ -46,7 +46,7 @@ var (
httpaddr
=
flag
.
String
(
"http"
,
""
,
"HTTP service address (e.g., ':6060')"
);
// layout control
html
=
flag
.
Bool
(
"html"
,
false
,
"print HTML in command-line mode"
);
html
=
flag
.
Bool
(
"html"
,
false
,
"print HTML in command-line mode"
);
)
...
...
@@ -79,7 +79,7 @@ func exec(c *http.Conn, args []string) (status int) {
return
2
;
}
status
=
wait
.
ExitStatus
();
if
!
wait
.
Exited
()
||
status
>
1
{
if
!
wait
.
Exited
()
||
status
>
1
{
os
.
Stderr
.
Write
(
buf
.
Bytes
());
log
.
Stderrf
(
"executing %v failed (exit status = %d)"
,
args
,
status
);
return
;
...
...
@@ -98,7 +98,7 @@ func exec(c *http.Conn, args []string) (status int) {
// Maximum directory depth, adjust as needed.
const
maxDirDepth
=
24
;
const
maxDirDepth
=
24
func
dosync
(
c
*
http
.
Conn
,
r
*
http
.
Request
)
{
args
:=
[]
string
{
"/bin/sh"
,
"-c"
,
*
syncCmd
};
...
...
@@ -125,7 +125,7 @@ func dosync(c *http.Conn, r *http.Request) {
func
usage
()
{
fmt
.
Fprintf
(
os
.
Stderr
,
"usage: godoc package [name ...]
\n
"
" godoc -http=:6060
\n
"
);
" godoc -http=:6060
\n
"
);
flag
.
PrintDefaults
();
os
.
Exit
(
2
);
}
...
...
src/cmd/godoc/spec.go
View file @
79284cae
...
...
@@ -125,7 +125,8 @@ func (p *ebnfParser) parseTerm() bool {
func
(
p
*
ebnfParser
)
parseSequence
()
{
for
p
.
parseTerm
()
{}
for
p
.
parseTerm
()
{
}
}
...
...
src/cmd/goyacc/doc.go
View file @
79284cae
...
...
@@ -17,7 +17,7 @@ Yacc adepts will have no trouble adapting to this form of the tool.
The file units.y in this directory is a yacc grammar for a version of
the Unix tool units, also written in Go and largely transliterated
from the Plan 9 C version.
from the Plan 9 C version.
*/
package
documentation
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment