Skip to content

Commit

Permalink
Move java_lite_proto_library docs from native to bzl file
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 597219780
Change-Id: Iaa192ec7363f9517573a7d81da5a7cbdaf91b76e
  • Loading branch information
comius authored and copybara-github committed Jan 10, 2024
1 parent 095ad38 commit 56f5d96
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import com.google.devtools.build.lib.bazel.rules.android.BazelAndroidToolsDefaultsJarRule;
import com.google.devtools.build.lib.bazel.rules.android.BazelDexArchiveAspect;
import com.google.devtools.build.lib.bazel.rules.android.BazelSdkToolchainRule;
import com.google.devtools.build.lib.bazel.rules.java.proto.BazelJavaLiteProtoLibraryRule;
import com.google.devtools.build.lib.bazel.rules.java.proto.BazelJavaProtoLibraryRule;
import com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryRule;
import com.google.devtools.build.lib.bazel.rules.python.BazelPyBuiltins;
Expand Down Expand Up @@ -348,7 +347,7 @@ public ImmutableList<RuleSet> requires() {
@Override
public void init(ConfiguredRuleClassProvider.Builder builder) {
builder.addRuleDefinition(new BazelJavaProtoLibraryRule());
builder.addRuleDefinition(new BazelJavaLiteProtoLibraryRule());
builder.addRuleDefinition(new BaseRuleClasses.EmptyRule("java_lite_proto_library") {});
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,43 @@ def _rule_impl(ctx):

java_lite_proto_library = rule(
implementation = _rule_impl,
doc = """
<p>
<code>java_lite_proto_library</code> generates Java code from <code>.proto</code> files.
</p>
<p>
<code>deps</code> must point to <a href="protocol-buffer.html#proto_library"><code>proto_library
</code></a> rules.
</p>
<p>
Example:
</p>
<pre class="code">
<code class="lang-starlark">
java_library(
name = "lib",
deps = [":foo"],
)
java_lite_proto_library(
name = "foo",
deps = [":bar"],
)
proto_library(
name = "bar",
)
</code>
</pre>
""",
attrs = {
"deps": attr.label_list(providers = [ProtoInfo], aspects = [java_lite_proto_aspect]),
"deps": attr.label_list(providers = [ProtoInfo], aspects = [java_lite_proto_aspect], doc = """
The list of <a href="protocol-buffer.html#proto_library"><code>proto_library</code></a>
rules to generate Java code for.
"""),
} | toolchains.if_legacy_toolchain({
PROTO_TOOLCHAIN_ATTR: attr.label(
default = configuration_field(fragment = "proto", name = "proto_toolchain_for_java_lite"),
Expand Down
5 changes: 5 additions & 0 deletions src/main/starlark/docgen/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ starlark_doc_extract(
name = "gen_be_proto_stardoc_proto",
src = "proto.bzl",
)

starlark_doc_extract(
name = "gen_be_java_stardoc_proto",
src = "java.bzl",
)
29 changes: 29 additions & 0 deletions src/main/starlark/docgen/java.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2023 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.

"""Java"""
# Build Encyclopedia entry point for Java rules implemented in Starlark in Blaze's @_builtins

binary_rules = struct(
)

library_rules = struct(
java_lite_proto_library = native.java_lite_proto_library,
)

test_rules = struct(
)

other_rules = struct(
)

0 comments on commit 56f5d96

Please sign in to comment.