-
-
Notifications
You must be signed in to change notification settings - Fork 739
Stardoc generates extras.md #2992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
070b8dd
WIP: generate stardoc output for embed_data rule and compare with che…
5a586ff
Kinda generate restructuredtext
3fb42b1
add updater
alexeagle 2cb268a
stardoc generates extras.md
153aa82
fixed difftest to only compare generated md and current md
ac60362
address comments
fd820da
add additional resources section
f670ebb
remove todo
82c60b9
convert go/extras.rst to stub, add issue tracking windows line ending…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| load("@bazel_skylib//rules:write_file.bzl", "write_file") | ||
| load("@bazel_skylib//rules:diff_test.bzl", "diff_test") | ||
| load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc") | ||
|
|
||
| _DOC_SRCS = { | ||
| "//extras:embed_data": "extras.md", | ||
| } | ||
|
|
||
| [ | ||
| stardoc( | ||
| name = out.replace(".md", "_docgen"), | ||
| out = out, | ||
| input = input + ".bzl", | ||
| deps = [input], | ||
| ) | ||
| for [ | ||
| input, | ||
| out, | ||
| ] in _DOC_SRCS.items() | ||
| ] | ||
|
|
||
| [ | ||
| diff_test( | ||
| name = "check_" + out, | ||
| failure_message = "Please run \"bazel run //docs:update\"", | ||
| # Source file | ||
| file1 = "//go:" + out, | ||
| # Output from stardoc rule above | ||
| file2 = out, | ||
| ) | ||
| for out in _DOC_SRCS.values() | ||
| ] | ||
|
|
||
| write_file( | ||
| name = "gen_update", | ||
| out = "update.sh", | ||
| content = [ | ||
| "#!/bin/sh", | ||
| "cd $BUILD_WORKSPACE_DIRECTORY", | ||
| ] + [ | ||
| "cp -fv bazel-bin/docs/{0} go/{0}".format(out) | ||
| for out in _DOC_SRCS.values() | ||
| ], | ||
| ) | ||
|
|
||
| sh_binary( | ||
| name = "update", | ||
| srcs = ["update.sh"], | ||
| data = _DOC_SRCS.values(), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| <!-- Generated with Stardoc: http://skydoc.bazel.build --> | ||
|
|
||
|
|
||
| [gazelle rule]: https://github.com/bazelbuild/bazel-gazelle#bazel-rule | ||
| [golang/mock]: https://github.com/golang/mock | ||
| [gomock_rule]: https://github.com/jmhodges/bazel_gomock | ||
| [core go rules]: core.rst | ||
|
|
||
| # Extra rules | ||
|
|
||
| This is a collection of helper rules. These are not core to building a go binary, but are supplied | ||
| to make life a little easier. | ||
|
|
||
| ## Contents | ||
| - [gazelle](#gazelle) | ||
| - [gomock](#gomock) | ||
| - [go_embed_data](#go_embed_data) | ||
|
|
||
| ## Additional resources | ||
| - [gazelle rule] | ||
| - [golang/mock] | ||
| - [gomock_rule] | ||
| - [core go rules] | ||
|
|
||
| ------------------------------------------------------------------------ | ||
|
|
||
| gazelle | ||
| ------- | ||
|
|
||
| This rule has moved. See [gazelle rule] in the Gazelle repository. | ||
|
|
||
| gomock | ||
| ------ | ||
|
|
||
| This rule allows you to generate mock interfaces with mockgen (from [golang/mock]) which can be useful for certain testing scenarios. See [gomock_rule] in the gomock repository. | ||
|
|
||
|
|
||
| <a id="#go_embed_data"></a> | ||
|
|
||
| ## go_embed_data | ||
|
|
||
| <pre> | ||
| go_embed_data(<a href="#go_embed_data-name">name</a>, <a href="#go_embed_data-flatten">flatten</a>, <a href="#go_embed_data-package">package</a>, <a href="#go_embed_data-src">src</a>, <a href="#go_embed_data-srcs">srcs</a>, <a href="#go_embed_data-string">string</a>, <a href="#go_embed_data-unpack">unpack</a>, <a href="#go_embed_data-var">var</a>) | ||
| </pre> | ||
|
|
||
| `go_embed_data` generates a .go file that contains data from a file or a | ||
| list of files. It should be consumed in the srcs list of one of the | ||
| [core go rules]. | ||
|
|
||
| Before using `go_embed_data`, you must add the following snippet to your | ||
| WORKSPACE: | ||
|
|
||
| ``` bzl | ||
| load("@io_bazel_rules_go//extras:embed_data_deps.bzl", "go_embed_data_dependencies") | ||
|
|
||
| go_embed_data_dependencies() | ||
| ``` | ||
|
|
||
| `go_embed_data` accepts the attributes listed below. | ||
|
|
||
|
|
||
| **ATTRIBUTES** | ||
|
|
||
|
|
||
| | Name | Description | Type | Mandatory | Default | | ||
| | :------------- | :------------- | :------------- | :------------- | :------------- | | ||
| | <a id="go_embed_data-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | | | ||
| | <a id="go_embed_data-flatten"></a>flatten | If <code>True</code> and <code>srcs</code> is used, map keys are file base names instead of relative paths. | Boolean | optional | False | | ||
| | <a id="go_embed_data-package"></a>package | Go package name for the generated .go file. | String | optional | "" | | ||
| | <a id="go_embed_data-src"></a>src | A single file to embed. This cannot be used at the same time as <code>srcs</code>. The generated file will have a variable of type <code>[]byte</code> or <code>string</code> with the contents of this file. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | | ||
| | <a id="go_embed_data-srcs"></a>srcs | A list of files to embed. This cannot be used at the same time as <code>src</code>. The generated file will have a variable of type <code>map[string][]byte</code> or <code>map[string]string</code> with the contents of each file. The map keys are relative paths of the files from the repository root. Keys for files in external repositories will be prefixed with <code>"external/repo/"</code> where "repo" is the name of the external repository. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] | | ||
| | <a id="go_embed_data-string"></a>string | If <code>True</code>, the embedded data will be stored as <code>string</code> instead of <code>[]byte</code>. | Boolean | optional | False | | ||
| | <a id="go_embed_data-unpack"></a>unpack | If <code>True</code>, sources are treated as archives and their contents will be stored. Supported formats are <code>.zip</code> and <code>.tar</code> | Boolean | optional | False | | ||
| | <a id="go_embed_data-var"></a>var | Name of the variable that will contain the embedded data. | String | optional | "Data" | | ||
|
|
||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.