aboutsummaryrefslogtreecommitdiff
path: root/devtools/cmd/css
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2020-09-09 00:23:17 -0400
committerJulie Qiu <julie@golang.org>2020-09-09 21:14:02 +0000
commit88f8a28ab2102416529d05d11e8135a43e146d46 (patch)
tree7a47f8f2f27a6d5ec3c63fd06d3a89947f830752 /devtools/cmd/css
parenta5c6be2ad47bc8eedd1286aaebb78a1c3e23709c (diff)
downloadgo-x-pkgsite-88f8a28ab2102416529d05d11e8135a43e146d46.tar.xz
devtools/cmd/css: various fixes
Package documentation is added to devtools/cmd/css and the css filepath is fixed since being moved from content/static/css. Change-Id: I4f12513a26c273e605a57c8101a1ed06f72e1b23 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/253609 Reviewed-by: Jamal Carvalho <jamal@golang.org>
Diffstat (limited to 'devtools/cmd/css')
-rw-r--r--devtools/cmd/css/main.go18
1 files changed, 5 insertions, 13 deletions
diff --git a/devtools/cmd/css/main.go b/devtools/cmd/css/main.go
index d6246d7c..54cd617f 100644
--- a/devtools/cmd/css/main.go
+++ b/devtools/cmd/css/main.go
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Command main reads from the CSS file at
+// Command css appends CSS styles to content/static/stylesheet.css.
+// It reads from the CSS file at
// https://github.com/sindresorhus/github-markdown-css/blob/gh-pages/github-markdown.css
// and removes all styles that do not belong to a .markdown-body <tag>. The
// .markdown-body class is then replaced with .Overview-readmeContent, for use
@@ -16,12 +17,11 @@ import (
"log"
"net/http"
"os"
- "path"
- "runtime"
"strings"
)
const (
+ cssFile = "content/static/stylesheet.css"
githubStylesheet = "https://raw.githubusercontent.com/sindresorhus/github-markdown-css/gh-pages/github-markdown.css"
githubREADMEClass = ".markdown-body"
discoveryREADMEClass = ".Overview-readmeContent"
@@ -72,15 +72,7 @@ func main() {
log.Fatal(err)
}
- // Get the abs path for content/static/css.
- _, filename, _, ok := runtime.Caller(0)
- if !ok {
- log.Fatal("No caller information")
- }
- dir := path.Dir(filename)
-
- f := dir + "/stylesheet.css"
- file, err := os.OpenFile(f, os.O_WRONLY|os.O_APPEND, 0644)
+ file, err := os.OpenFile(cssFile, os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
log.Fatalf("os.OpenFile(f, os.O_WRONLY|os.O_APPEND, 0644): %v", err)
}
@@ -93,7 +85,7 @@ func main() {
if !*write {
fmt.Println("Dryrun only. Run with `-write` to write to stylesheet.css.")
} else {
- fmt.Printf("Writing these properties to %q: \n", f)
+ fmt.Printf("Writing these properties to %q: \n", cssFile)
}
contentsToWrite := `