diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index e2d0407..e17762f 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -1,10 +1,8 @@ --- build_targets: &build_targets - "//..." - - "-//docs/..." test_targets: &test_targets - "//..." - - "-//docs/..." buildifier: version: latest @@ -127,15 +125,3 @@ tasks: test_flags: - "--config=bzlmod" test_targets: *test_targets -# docs: -# name: "Docs" -# bazel: last_green -# platform: ubuntu2004 -# build_flags: -# - "--config=bzlmod" -# build_targets: -# - "//docs/..." -# test_flags: -# - "--config=bzlmod" -# test_targets: -# - "//docs/..." diff --git a/.gitattributes b/.gitattributes index 3194ddf..dd07241 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,3 @@ -# In code review, collapse generated files -docs/*.md linguist-generated=true - # Configuration for 'git archive' # see https://git-scm.com/docs/git-archive/2.40.0#ATTRIBUTES # Omit folders that users don't need, making the distribution artifact smaller diff --git a/MODULE.bazel b/MODULE.bazel index 619f99e..2a69659 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -13,7 +13,5 @@ bazel_dep(name = "rules_cc", version = "0.0.15") bazel_dep(name = "rules_license", version = "0.0.7") # Dependencies needed in tests -bazel_dep(name = "stardoc", version = "0.7.1", dev_dependency = True, repo_name = "io_bazel_stardoc") -bazel_dep(name = "rules_shell", version = "0.2.0", dev_dependency = True) # only used in docs bazel_dep(name = "platforms", version = "0.0.8", dev_dependency = True) bazel_dep(name = "googletest", version = "1.11.0", dev_dependency = True, repo_name = "com_google_googletest") diff --git a/docs/BUILD b/docs/BUILD deleted file mode 100644 index 9349d4a..0000000 --- a/docs/BUILD +++ /dev/null @@ -1,12 +0,0 @@ -load(":stardoc_with_diff_test.bzl", "stardoc_with_diff_test", "update_docs") - -stardoc_with_diff_test( - name = "defs", - bzl_library_target = "//proto:defs", - out_label = "//docs:defs.md", -) - -update_docs( - name = "update", - docs_folder = "docs", -) diff --git a/docs/defs.md b/docs/defs.md deleted file mode 100644 index 6c39139..0000000 --- a/docs/defs.md +++ /dev/null @@ -1,74 +0,0 @@ - - -Starlark rules for building protocol buffers. - - - -## proto_descriptor_set - -
-proto_descriptor_set(name, deps)
-
- -Collects all `FileDescriptorSet`s from `deps` and combines them into a single -`FileDescriptorSet` containing all the `FileDescriptorProto`. - -**ATTRIBUTES** - - -| Name | Description | Type | Mandatory | Default | -| :------------- | :------------- | :------------- | :------------- | :------------- | -| name | A unique name for this target. | Name | required | | -| deps | Sequence of ProtoInfos to collect FileDescriptorSets from. | List of labels | optional | [] | - - - - -## proto_lang_toolchain - -
-proto_lang_toolchain(name, toolchain_type, exec_compatible_with, target_compatible_with, attrs)
-
- -Creates a proto_lang_toolchain and corresponding toolchain target. - -Toolchain target is only created when toolchain_type is set. - -https://docs.bazel.build/versions/master/be/protocol-buffer.html#proto_lang_toolchain - - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| name | name of the toolchain | none | -| toolchain_type | The toolchain type | None | -| exec_compatible_with | ([constraints]) List of constraints the prebuild binaries is compatible with. | [] | -| target_compatible_with | ([constraints]) List of constraints the target libraries are compatible with. | [] | -| attrs | Rule attributes | none | - - - - -## proto_toolchain - -
-proto_toolchain(name, proto_compiler, exec_compatible_with)
-
- -Creates a proto_toolchain and toolchain target for proto_library. - -Toolchain target is suffixed with "_toolchain". - - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| name | name of the toolchain | none | -| proto_compiler | (Label) of either proto compiler sources or prebuild binaries | none | -| exec_compatible_with | ([constraints]) List of constraints the prebuild binary is compatible with. | [] | - - diff --git a/docs/stardoc_with_diff_test.bzl b/docs/stardoc_with_diff_test.bzl deleted file mode 100644 index 3575621..0000000 --- a/docs/stardoc_with_diff_test.bzl +++ /dev/null @@ -1,111 +0,0 @@ -# Copyright 2022 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Helpers for keeping stardoc documentation up-to-date. - -These are currently a private API in bazel-skylib. -See discussion: -https://github.com/bazelbuild/bazel-skylib/pull/321#issuecomment-1081166216 - -If you need a similar feature, you can consider using a similar rule -available from a third-party: -https://github.com/aspect-build/bazel-lib/blob/main/docs/docs.md -""" - -load("@bazel_skylib//rules:diff_test.bzl", "diff_test") -load("@bazel_skylib//rules:write_file.bzl", "write_file") -load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc") -load("@rules_shell//shell:sh_binary.bzl", "sh_binary") - -def stardoc_with_diff_test( - name, - bzl_library_target, - out_label): - """Creates a stardoc target coupled with a `diff_test` for a given `bzl_library`. - - This is helpful for minimizing boilerplate in repos with lots of stardoc targets. - - Args: - name: the stardoc target name - bzl_library_target: the label of the `bzl_library` target to generate documentation for - out_label: the label of the output MD file - """ - out_file = out_label.replace("//", "").replace(":", "/") - - # Generate MD from .bzl - stardoc( - name = name, - out = out_file.replace(".md", "-docgen.md"), - input = bzl_library_target + ".bzl", - deps = [bzl_library_target], - ) - - # Ensure that the generated MD has been updated in the local source tree - diff_test( - name = out_file.replace("/", "_").replace(".md", "-difftest"), - failure_message = "Please run \"bazel run //docs:update\"", - # Source file - file1 = out_label, - # Output from stardoc rule above - file2 = out_file.replace(".md", "-docgen.md"), - tags = ["no_windows"], - ) - -def update_docs( - name = "update", - docs_folder = "docs"): - """Creates a `sh_binary` target which copies over generated doc files to the local source tree. - - This is to be used in tandem with `stardoc_with_diff_test()` to produce a convenient workflow - for generating, testing, and updating all doc files as follows: - - ``` bash - bazel build //{docs_folder}/... && bazel test //{docs_folder}/... && bazel run //{docs_folder}:update - ``` - - eg. - - ``` bash - bazel build //docs/... && bazel test //docs/... && bazel run //docs:update - ``` - - The `update_docs()` invocation must come after/below any `stardoc_with_diff_test()` invocations - in the BUILD file. - - Args: - name: the name of the `sh_binary` target - docs_folder: the name of the folder containing the doc files in the local source tree - """ - content = ["#!/usr/bin/env bash", "cd ${BUILD_WORKSPACE_DIRECTORY}"] - data = [] - for r in native.existing_rules().values(): - if r["kind"] == "stardoc": - doc_gen = r["out"] - if doc_gen.startswith(":"): - doc_gen = doc_gen[1:] - doc_dest = doc_gen.replace("-docgen.md", ".md") - data.append(doc_gen) - content.append("cp -fv bazel-bin/{0}/{1} {2}".format(docs_folder, doc_gen, doc_dest)) - - update_script = name + ".sh" - write_file( - name = "gen_" + name, - out = update_script, - content = content, - ) - - sh_binary( - name = name, - srcs = [update_script], - data = data, - ) diff --git a/proto/BUILD b/proto/BUILD index 7f8b70b..d819e92 100644 --- a/proto/BUILD +++ b/proto/BUILD @@ -1,10 +1,5 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -exports_files( - glob(["*.bzl"]), - visibility = ["//docs:__pkg__"], -) - bzl_library( name = "defs", srcs = [