Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
79284cae
Commit
79284cae
authored
Nov 06, 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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
32 deletions
+32
-32
godoc.go
src/cmd/godoc/godoc.go
+25
-26
main.go
src/cmd/godoc/main.go
+4
-4
spec.go
src/cmd/godoc/spec.go
+2
-1
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 (
...
@@ -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
()
{
func
init
()
{
...
@@ -139,9 +139,9 @@ func htmlEscape(s string) string {
...
@@ -139,9 +139,9 @@ func htmlEscape(s string) string {
// Package directories
// Package directories
type
Directory
struct
{
type
Directory
struct
{
Path
string
;
// includes Name
Path
string
;
// includes Name
Name
string
;
Name
string
;
Dirs
[]
*
Directory
;
Dirs
[]
*
Directory
;
}
}
...
@@ -153,7 +153,7 @@ func newDirTree(path, name string, depth int) *Directory {
...
@@ -153,7 +153,7 @@ func newDirTree(path, name string, depth int) *Directory {
return
&
Directory
{
path
,
name
,
nil
};
return
&
Directory
{
path
,
name
,
nil
};
}
}
list
,
_
:=
io
.
ReadDir
(
path
);
// ignore errors
list
,
_
:=
io
.
ReadDir
(
path
);
// ignore errors
// determine number of subdirectories and package files
// determine number of subdirectories and package files
ndirs
:=
0
;
ndirs
:=
0
;
...
@@ -210,7 +210,7 @@ func newDirectory(root string, depth int) *Directory {
...
@@ -210,7 +210,7 @@ func newDirectory(root string, depth int) *Directory {
// lookup looks for the *Directory for a given path, relative to dir.
// lookup looks for the *Directory for a given path, relative to dir.
func
(
dir
*
Directory
)
lookup
(
path
string
)
*
Directory
{
func
(
dir
*
Directory
)
lookup
(
path
string
)
*
Directory
{
path
=
pathutil
.
Clean
(
path
);
// no trailing '/'
path
=
pathutil
.
Clean
(
path
);
// no trailing '/'
if
dir
==
nil
||
path
==
""
||
path
==
"."
{
if
dir
==
nil
||
path
==
""
||
path
==
"."
{
return
dir
;
return
dir
;
...
@@ -224,7 +224,7 @@ func (dir *Directory) lookup(path string) *Directory {
...
@@ -224,7 +224,7 @@ func (dir *Directory) lookup(path string) *Directory {
return
d
;
return
d
;
}
}
}
}
return
nil
return
nil
;
}
}
return
dir
.
lookup
(
dpath
)
.
lookup
(
dname
);
return
dir
.
lookup
(
dpath
)
.
lookup
(
dname
);
...
@@ -404,7 +404,7 @@ func htmlFmt(w io.Writer, x interface{}, format string) {
...
@@ -404,7 +404,7 @@ func htmlFmt(w io.Writer, x interface{}, format string) {
func
htmlCommentFmt
(
w
io
.
Writer
,
x
interface
{},
format
string
)
{
func
htmlCommentFmt
(
w
io
.
Writer
,
x
interface
{},
format
string
)
{
var
buf
bytes
.
Buffer
;
var
buf
bytes
.
Buffer
;
writeAny
(
&
buf
,
x
,
false
);
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) {
...
@@ -416,7 +416,7 @@ func textFmt(w io.Writer, x interface{}, format string) {
// Template formatter for "dir" format.
// Template formatter for "dir" format.
func
dirFmt
(
w
io
.
Writer
,
x
interface
{},
format
string
)
{
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
{
if
err
:=
dirsHtml
.
Execute
(
x
,
w
);
err
!=
nil
{
log
.
Stderrf
(
"dirsHtml.Execute: %s"
,
err
);
log
.
Stderrf
(
"dirsHtml.Execute: %s"
,
err
);
}
}
...
@@ -425,7 +425,7 @@ func dirFmt(w io.Writer, x interface{}, format string) {
...
@@ -425,7 +425,7 @@ func dirFmt(w io.Writer, x interface{}, format string) {
func
removePrefix
(
s
,
prefix
string
)
string
{
func
removePrefix
(
s
,
prefix
string
)
string
{
if
strings
.
HasPrefix
(
s
,
prefix
)
{
if
strings
.
HasPrefix
(
s
,
prefix
)
{
return
s
[
len
(
prefix
)
:
len
(
s
)];
return
s
[
len
(
prefix
)
:
len
(
s
)];
}
}
return
s
;
return
s
;
}
}
...
@@ -471,7 +471,7 @@ var infoClasses = [nKinds]string{
...
@@ -471,7 +471,7 @@ var infoClasses = [nKinds]string{
// Template formatter for "infoClass" format.
// Template formatter for "infoClass" format.
func
infoClassFmt
(
w
io
.
Writer
,
x
interface
{},
format
string
)
{
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 {
...
@@ -530,12 +530,12 @@ func readTemplate(name string) *template.Template {
var
(
var
(
dirsHtml
,
dirsHtml
,
godocHtml
,
godocHtml
,
packageHtml
,
packageHtml
,
packageText
,
packageText
,
parseerrorHtml
,
parseerrorHtml
,
parseerrorText
,
parseerrorText
,
searchHtml
*
template
.
Template
;
searchHtml
*
template
.
Template
;
)
)
func
readTemplates
()
{
func
readTemplates
()
{
...
@@ -694,9 +694,9 @@ type PageInfo struct {
...
@@ -694,9 +694,9 @@ type PageInfo struct {
type
httpHandler
struct
{
type
httpHandler
struct
{
pattern
string
;
// url pattern; e.g. "/pkg/"
pattern
string
;
// url pattern; e.g. "/pkg/"
fsRoot
string
;
// file system root to which the pattern is mapped
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)
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 {
...
@@ -754,14 +754,14 @@ func (h *httpHandler) getPageInfo(path string) PageInfo {
// or command-line mode); compute one level for this page
// or command-line mode); compute one level for this page
dir
=
newDirectory
(
dirname
,
1
);
dir
=
newDirectory
(
dirname
,
1
);
}
}
return
PageInfo
{
pdoc
,
dir
,
h
.
isPkg
};
return
PageInfo
{
pdoc
,
dir
,
h
.
isPkg
};
}
}
func
(
h
*
httpHandler
)
ServeHTTP
(
c
*
http
.
Conn
,
r
*
http
.
Request
)
{
func
(
h
*
httpHandler
)
ServeHTTP
(
c
*
http
.
Conn
,
r
*
http
.
Request
)
{
path
:=
r
.
Url
.
Path
;
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
// canonicalize URL path and redirect if necessary
if
canonical
:=
pathutil
.
Clean
(
h
.
pattern
+
path
)
+
"/"
;
r
.
Url
.
Path
!=
canonical
{
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) {
...
@@ -797,7 +797,7 @@ func (h *httpHandler) ServeHTTP(c *http.Conn, r *http.Request) {
_
,
pkgname
:=
pathutil
.
Split
(
pathutil
.
Clean
(
path
));
_
,
pkgname
:=
pathutil
.
Split
(
pathutil
.
Clean
(
path
));
title
=
"Command "
+
pkgname
;
title
=
"Command "
+
pkgname
;
default
:
default
:
title
=
"Command "
+
info
.
PDoc
.
PackageName
title
=
"Command "
+
info
.
PDoc
.
PackageName
;
}
}
}
}
...
@@ -850,8 +850,8 @@ func search(c *http.Conn, r *http.Request) {
...
@@ -850,8 +850,8 @@ func search(c *http.Conn, r *http.Request) {
// Server
// Server
var
(
var
(
cmdHandler
=
httpHandler
{
"/cmd/"
,
*
cmdroot
,
false
};
cmdHandler
=
httpHandler
{
"/cmd/"
,
*
cmdroot
,
false
};
pkgHandler
=
httpHandler
{
"/pkg/"
,
*
pkgroot
,
true
};
pkgHandler
=
httpHandler
{
"/pkg/"
,
*
pkgroot
,
true
};
)
)
...
@@ -885,4 +885,3 @@ func indexer() {
...
@@ -885,4 +885,3 @@ func indexer() {
time
.
Sleep
(
1
*
60e9
);
// try once a minute
time
.
Sleep
(
1
*
60e9
);
// try once a minute
}
}
}
}
src/cmd/godoc/main.go
View file @
79284cae
...
@@ -46,7 +46,7 @@ var (
...
@@ -46,7 +46,7 @@ var (
httpaddr
=
flag
.
String
(
"http"
,
""
,
"HTTP service address (e.g., ':6060')"
);
httpaddr
=
flag
.
String
(
"http"
,
""
,
"HTTP service address (e.g., ':6060')"
);
// layout control
// 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) {
...
@@ -79,7 +79,7 @@ func exec(c *http.Conn, args []string) (status int) {
return
2
;
return
2
;
}
}
status
=
wait
.
ExitStatus
();
status
=
wait
.
ExitStatus
();
if
!
wait
.
Exited
()
||
status
>
1
{
if
!
wait
.
Exited
()
||
status
>
1
{
os
.
Stderr
.
Write
(
buf
.
Bytes
());
os
.
Stderr
.
Write
(
buf
.
Bytes
());
log
.
Stderrf
(
"executing %v failed (exit status = %d)"
,
args
,
status
);
log
.
Stderrf
(
"executing %v failed (exit status = %d)"
,
args
,
status
);
return
;
return
;
...
@@ -98,7 +98,7 @@ func exec(c *http.Conn, args []string) (status int) {
...
@@ -98,7 +98,7 @@ func exec(c *http.Conn, args []string) (status int) {
// Maximum directory depth, adjust as needed.
// Maximum directory depth, adjust as needed.
const
maxDirDepth
=
24
;
const
maxDirDepth
=
24
func
dosync
(
c
*
http
.
Conn
,
r
*
http
.
Request
)
{
func
dosync
(
c
*
http
.
Conn
,
r
*
http
.
Request
)
{
args
:=
[]
string
{
"/bin/sh"
,
"-c"
,
*
syncCmd
};
args
:=
[]
string
{
"/bin/sh"
,
"-c"
,
*
syncCmd
};
...
@@ -125,7 +125,7 @@ func dosync(c *http.Conn, r *http.Request) {
...
@@ -125,7 +125,7 @@ func dosync(c *http.Conn, r *http.Request) {
func
usage
()
{
func
usage
()
{
fmt
.
Fprintf
(
os
.
Stderr
,
fmt
.
Fprintf
(
os
.
Stderr
,
"usage: godoc package [name ...]
\n
"
"usage: godoc package [name ...]
\n
"
" godoc -http=:6060
\n
"
);
" godoc -http=:6060
\n
"
);
flag
.
PrintDefaults
();
flag
.
PrintDefaults
();
os
.
Exit
(
2
);
os
.
Exit
(
2
);
}
}
...
...
src/cmd/godoc/spec.go
View file @
79284cae
...
@@ -125,7 +125,8 @@ func (p *ebnfParser) parseTerm() bool {
...
@@ -125,7 +125,8 @@ func (p *ebnfParser) parseTerm() bool {
func
(
p
*
ebnfParser
)
parseSequence
()
{
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.
...
@@ -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 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
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
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