| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A documentation site generator that fits Sourcegraph's needs:
go get github.com/sourcegraph/docsite/cmd/docsite
docsite -hTo use docsite for docs.sourcegraph.com, see "Documentation site" in the Sourcegraph documentation.
The docsite check command runs various checks on your documentation site to find problems:
If any problems are found, it exits with a non-zero status code.
To ignore the disconnected page check for a page, add YAML ignoreDisconnectedPageCheck: true to the top matter in the beginning of the .md file. For example:
--- ignoreDisconnectedPageCheck: true --- # My page title
The site data describes the location of its templates, assets, and content. It is a JSON object with the following properties.
The possible values for VFS URLs are:
A relative path to a local directory (such as ../myrepo/doc). The path is interpreted relative to the docsite.json file (if it exists) or the current working directory (if site data is specified in DOCSITE_CONFIG).
An absolute URL to a Zip archive (with http or https scheme). The URL can contain a fragment (such as #mydir/) to refer to a specific directory in the archive.
If the URL fragment contains a path component * (such as #*/templates/), it matches the first top-level directory in the Zip file. (This is useful when using GitHub Zip archive URLs, such as https://codeload.github.com/alice/myrepo/zip/myrev#*/templates/. GitHub produces Zip archives with a top-level directory $REPO-$REV, such as myrepo-myrev, and using #*/templates/ makes it easy to descend into that top-level directory without needing to duplicate the myrev in the URL fragment.)
If the URL contains the literal string $VERSION, it is replaced by the user's requested version from the URL (e.g., the URL path /@foo/bar means the version is foo). ⚠️ If you are using GitHub codeload.github.com archive URLs, be sure your URL contains refs/heads/$VERSION (as in https://codeload.github.com/owner/repo/zip/refs/heads/$VERSION), not just $VERSION. This prevents someone from forking your repository, pushing a commit to their fork with unauthorized content, and then crafting a URL on your documentation site that would cause users to view that unauthorized content (which may contain malicious scripts or misleading information).
The templates use Go-style HTML templates.
See the following examples:
In addition to the redirects property in site data, you can also specify redirects in a text file named redirects at the top level of the assets VFS. The format is as follows:
FROM-PATH TO-URL STATUS-CODE
For example:
# Comments are allowed
/my/old/page /my/new/page 308
/another/page https://example.com/page 308
The docsite tool requires site data to be available in any of the following ways:
{
"content": "../sourcegraph/doc",
"baseURLPath": "/",
"templates": "templates",
"assets": "assets",
"assetsBaseURLPath": "/assets/",
"check": {
"ignoreURLPattern": "(^https?://)|(^#)|(^mailto:support@sourcegraph\\.com$)|(^chrome://)"
}
}DOCSITE_CONFIG='{"templates":"https://codeload.github.com/sourcegraph/sourcegraph-public-snapshot/zip/refs/heads/main#*/doc/_resources/templates/","assets":"https://codeload.github.com/sourcegraph/sourcegraph/zip/refs/heads/main#*/doc/_resources/assets/","content":"https://codeload.github.com/sourcegraph/sourcegraph/zip/refs/heads/$VERSION#*/doc/","baseURLPath":"/","assetsBaseURLPath":"/assets/","defaultContentBranch":"main"}' docsite serve
To run docsite locally and serve on port :5080, run:
go run ./cmd/docsite/... -config docsite.json serveFor certain use cases you want to have docsite download the docs content as it does with production configuration. To force this behaviour locally you can set "forceServedDownloadedContent": true in you docsite.json configuration
Build the Docker image for linux/amd64:
docker build -t sourcegraph/docsite .
# Use buildx if you're on M1
docker buildx build --platform linux/amd64 -t sourcegraph/docsite .Tag and push the image to Docker Hub and GCR:
export VERSION= # e.g. v1.9.1
docker tag sourcegraph/docsite sourcegraph/docsite:$VERSION
docker push sourcegraph/docsite
docker push sourcegraph/docsite:$VERSIONFor internal Sourcegraph usage:
For development, bump the version number in files that define DOCSITE_VERSION.
| Back | FazBrowse Home | New Git URL |