xref: /aosp_15_r20/external/stardoc/stardoc/proto/stardoc_output.proto (revision b2fa42943c124aa9c7163734493fc7a7559681cf)
1// Copyright 2019 The Bazel Authors. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//    http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Protos for Stardoc data.
16//
17// Stardoc collects information about Starlark functions, providers, and rules.
18syntax = "proto3";
19
20package stardoc_output;
21
22// option java_api_version = 2;
23option java_package = "com.google.devtools.build.skydoc.rendering.proto";
24option java_outer_classname = "StardocOutputProtos";
25
26// The root output proto of Stardoc. A single invocation of Stardoc will output
27// exactly one instance of this proto, representing all documentation for
28// the input Starlark file.
29message ModuleInfo {
30  repeated RuleInfo rule_info = 1;
31
32  repeated ProviderInfo provider_info = 2;
33
34  repeated StarlarkFunctionInfo func_info = 3;
35
36  repeated AspectInfo aspect_info = 4;
37
38  // The docstring present at the top of the input Starlark file.
39  string module_docstring = 5;
40}
41
42// Representation of a Starlark rule attribute type. These generally
43// have a one-to-one correspondence with functions defined at
44// https://bazel.build/rules/lib/attr.
45enum AttributeType {
46  UNKNOWN = 0;
47  // A special case of STRING; all rules have exactly one implicit
48  // attribute "name" of type NAME.
49  NAME = 1;
50  INT = 2;
51  LABEL = 3;
52  STRING = 4;
53  STRING_LIST = 5;
54  INT_LIST = 6;
55  LABEL_LIST = 7;
56  BOOLEAN = 8;
57  LABEL_STRING_DICT = 9;
58  STRING_DICT = 10;
59  STRING_LIST_DICT = 11;
60  OUTPUT = 12;
61  OUTPUT_LIST = 13;
62}
63
64// Representation of a Starlark rule definition.
65message RuleInfo {
66  // The name of the rule.
67  string rule_name = 1;
68
69  // The documentation string of the rule.
70  string doc_string = 2;
71
72  // The attributes of the rule.
73  repeated AttributeInfo attribute = 3;
74}
75
76// Representation of a Starlark rule attribute definition, comprised of an
77// attribute name, and a schema defined by a call to one of the 'attr' module
78// methods enumerated at
79// https://bazel.build/rules/lib/attr
80message AttributeInfo {
81  // The name of the attribute.
82  string name = 1;
83
84  // The documentation string of the attribute, supplied via the 'doc'
85  // parameter to the schema-creation call.
86  string doc_string = 2;
87
88  // The type of the attribute, defined generally by which function is invoked
89  // in the attr module.
90  AttributeType type = 3;
91
92  // If true, all targets of the rule must specify a value for this attribute.
93  bool mandatory = 4;
94
95  // The target(s) in this attribute must define all the providers of at least
96  // one of the ProviderNameGroups in this list. If the Attribute Type is not a
97  // label, a label list, or a label-keyed string dictionary, the field will be
98  // left empty.
99  repeated ProviderNameGroup provider_name_group = 5;
100
101  // The string representation of the default value of this attribute.
102  string default_value = 6;
103}
104
105// Representation of a set of providers that a rule attribute may be required to
106// have.
107message ProviderNameGroup {
108  // The names of the providers that must be given by any dependency appearing
109  // in this attribute. The name will be "Unknown Provider" if the name is
110  // unidentifiable, for example, if the provider is part of a namespace.
111  // TODO(kendalllane): Fix documentation of providers from namespaces.
112  repeated string provider_name = 1;
113}
114
115// Representation of Starlark function definition.
116message StarlarkFunctionInfo {
117  // The name of the function.
118  string function_name = 1;
119
120  // The parameters for the function.
121  repeated FunctionParamInfo parameter = 2;
122
123  // The documented description of the function (if specified in the function's
124  // docstring).
125  string doc_string = 3;
126
127  // The return value for the function.
128  FunctionReturnInfo return = 4;
129
130  // The deprecation for the function.
131  FunctionDeprecationInfo deprecated = 5;
132}
133
134// Representation of a Starlark function parameter definition.
135message FunctionParamInfo {
136  // The name of the parameter.
137  string name = 1;
138
139  // The documented description of the parameter (if specified in the function's
140  // docstring).
141  string doc_string = 2;
142
143  // If not an empty string, the default value of the parameter displayed
144  // as a string.
145  string default_value = 3;
146
147  // If true, the default value is unset and a value is needed for this
148  // parameter. This might be false even if defaultValue is empty in the case of
149  // special parameter such as *args and **kwargs"
150  bool mandatory = 4;
151}
152
153message FunctionReturnInfo {
154  // The documented return value of the function (if specified in the function's
155  // docstring).
156  string doc_string = 1;
157}
158
159message FunctionDeprecationInfo {
160  // The documented deprecation of the function (if specified in the function's
161  // docstring).
162  string doc_string = 1;
163}
164
165// Representation of a Starlark provider field definition, comprised of
166// the field name and provider description.
167message ProviderFieldInfo {
168  // The name of the field.
169  string name = 1;
170
171  // The description of the provider.
172  string doc_string = 2;
173}
174
175// Representation of a Starlark provider definition.
176message ProviderInfo {
177  // The name of the provider.
178  string provider_name = 1;
179
180  // The description of the provider.
181  string doc_string = 2;
182
183  // The fields of the provider.
184  repeated ProviderFieldInfo field_info = 3;
185}
186
187// Representation of a Starlark aspect definition.
188message AspectInfo {
189  // The name of the aspect.
190  string aspect_name = 1;
191
192  // The documentation string of the aspect.
193  string doc_string = 2;
194
195  // The rule attributes along which the aspect propagates.
196  repeated string aspect_attribute = 3;
197
198  // The attributes of the aspect.
199  repeated AttributeInfo attribute = 4;
200}
201