Revert "*: update docs for hackdoc"
This reverts commit cc8c69c8974f7ce415641121cedb01d7e6aa9e17.
Reason for revert: <INSERT REASONING HERE>
Change-Id: I1315e930e2ef69db3188eda05e4aa0b12db24274
diff --git a/devtools/hackdoc/README.md b/devtools/hackdoc/README.md
index 3226cf2..45d4486 100644
--- a/devtools/hackdoc/README.md
+++ b/devtools/hackdoc/README.md
@@ -18,6 +18,6 @@
To run hackdoc locally on a filesystem checkout (ie. when working on docs, templates, or hackdoc itself), run:
- bazel run //devtools/hackdoc -- -hspki_disable -docroot /path/to/hscloud
+ bazel run //devtools/hackdoc:local
The output log should tell you where hackdoc just started listening at. Currently this is `127.0.0.1:8080` by default. You can change this by passing a `-listen` flag, eg. `-listen 127.0.0.1:4242`.
diff --git a/devtools/hackdoc/main.go b/devtools/hackdoc/main.go
index 413a129..558268b 100644
--- a/devtools/hackdoc/main.go
+++ b/devtools/hackdoc/main.go
@@ -111,6 +111,7 @@
return
}
+ glog.Infof("%+v", r.URL.Query())
ref := r.URL.Query().Get("ref")
if ref == "" {
ref = flagGitwebDefaultBranch
@@ -205,8 +206,7 @@
}
if file {
- http.Redirect(r.w, r.r, "/"+fpath, 302)
- //r.handleMarkdown(fpath, cfg)
+ r.handleMarkdown(fpath, cfg)
return
}
}
@@ -238,11 +238,6 @@
if file {
parts := strings.Split(r.rpath, "/")
dirpath := strings.Join(parts[:(len(parts)-1)], "/")
- // TODO(q3k): figure out this hack, hopefully by implementing a real path type
- if dirpath == "/" {
- dirpath = "//"
- }
-
cfg, err := config.ForPath(r.ctx, r.source, dirpath)
if err != nil {
glog.Errorf("could not get config for path %q: %w", dirpath, err)
diff --git a/devtools/hackdoc/markdown.go b/devtools/hackdoc/markdown.go
index d20f9e3..911c2c0 100644
--- a/devtools/hackdoc/markdown.go
+++ b/devtools/hackdoc/markdown.go
@@ -31,7 +31,6 @@
q["ref"] = []string{ref}
u.RawQuery = q.Encode()
node.Destination = []byte(u.String())
- glog.Infof("link fix %q -> %q", dest, u.String())
}
}
return r.RenderNode(&buf, node, entering)
@@ -39,11 +38,6 @@
return buf.Bytes()
}
-type pathPart struct {
- Label string
- Path string
-}
-
func (r *request) handleMarkdown(path string, cfg *config.Config) {
data, err := r.source.ReadFile(r.ctx, path)
if err != nil {
@@ -66,26 +60,11 @@
}
pathInDepot := strings.TrimPrefix(path, "//")
- pathParts := []pathPart{
- {Label: "//", Path: "/"},
- }
- parts := strings.Split(pathInDepot, "/")
- fullPath := ""
- for i, p := range parts {
- label := p
- if i != len(parts)-1 {
- label = label + "/"
- }
- fullPath += "/" + p
- pathParts = append(pathParts, pathPart{Label: label, Path: fullPath})
- }
-
vars := map[string]interface{}{
"Rendered": template.HTML(rendered),
"Title": path,
"Path": path,
"PathInDepot": pathInDepot,
- "PathParts": pathParts,
"HackdocURL": flagHackdocURL,
"WebLinks": r.source.WebLinks(pathInDepot),
}
diff --git a/devtools/hackdoc/tpl/default.html b/devtools/hackdoc/tpl/default.html
index a6c1d42..7120962 100644
--- a/devtools/hackdoc/tpl/default.html
+++ b/devtools/hackdoc/tpl/default.html
@@ -58,7 +58,7 @@
}
.column {
- width: 80em;
+ max-width: 80em;
padding: 1rem 0 1rem 0;
}
@@ -85,16 +85,8 @@
color: #b30014;
}
-.header span.part {
+.header span.muted {
color: #666;
- padding-left: 0.2em;
-}
-
-.header span.part a {
- color: rgb(27, 106, 203);
-}
-.header span.part a:visited {
- color: rgb(27, 106, 203);
}
.footer {
@@ -106,14 +98,6 @@
text-align: right;
}
-.footer .left {
- float: left;
-}
-
-.footer .right {
- float: right;
-}
-
.footer a {
color: #bbb;
}
@@ -180,20 +164,15 @@
<div class="column">
<div class="page">
<div class="header">
- <span class="red">hackdoc:</span>
- {{ range .PathParts }}<span class="part"><a href="{{ .Path }}">{{ .Label }}</a></span>{{ end }}
- <span class="red" style="margin-left: 1em;">shortcuts:</span> <a href="/">root</a>, <a href="/cluster/doc">cluster docs</a>, <a href="/doc/codelabs">codelabs</a>
- </div>
- {{ .Rendered }}
- </div>
- <div class="footer">
- <div class="left">
- View in:
+ <span class="red">hackdoc:</span><span>{{ .Path }}</span>
{{ range .WebLinks }}
<span class="muted">[{{ .Kind }} <a href="{{ .LinkURL }}">{{ .LinkLabel }}</a>]</span>
{{ end }}
</div>
- <div class="right">Generated by <a href="{{ .HackdocURL }}/devtools/hackdoc">hackdoc</a>.</div>
+ {{ .Rendered }}
+ </div>
+ <div class="footer">
+ Generated by <a href="{{ .HackdocURL }}/devtools/hackdoc">hackdoc</a>.
</div>
</div>
</div>