You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-67Lines changed: 4 additions & 67 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -171,79 +171,16 @@ doxygen(
171
171
)
172
172
```
173
173
174
+
> [!Note]
175
+
> `srcs` and `deps` attributes are **not** interchangeable.
176
+
> Use `srcs` with files and when you want to capture the output of another rule, and use `deps` when you want to capture the source files of other rules transitively.
177
+
174
178
Use the [Doxygen documentation](https://www.doxygen.nl/manual/config.html) or generate a brand new _Doxyfile_ with `doxygen -g` to see all the available options to put in the `configurations` list.
175
179
They will simply be appended at the end of the file, overriding the default values.
176
180
177
181
> [!Note]
178
182
> See the [documentation](docs/doxygen_doc.md) for more information or the [examples](examples) directory for examples of how to use the rules.
179
183
180
-
### Differences between `srcs` and `deps`
181
-
182
-
The `srcs` and `deps` attributes work differently, and are not interchangeable.
183
-
184
-
`srcs` is a list of files that will be passed to Doxygen for documentation generation.
185
-
You can use `glob` to include a collection of multiple files.
186
-
On the other hand, if you indicate a target (e.g., `:my_genrule`), it will include all the files produced by that target.
187
-
More precisely, the files in the DefaultInfo provider the target returns.
188
-
Hence, when the documentation is generated, all rules in the `srcs` attribute **will** be built, and the files they output will be passed to Doxygen.
189
-
190
-
On the other hand, `deps` is a list of targets whose sources will be included in the documentation generation.
191
-
It will automatically include all the files in the `srcs`, `hdrs`, and `data` attributes of the target, and the same applies to all of its transitive dependencies, recursively.
192
-
Since we are only interested in the source files, the `deps` targets **will not** be built when the documentation is generated.
193
-
194
-
```bzl
195
-
# My BUILD.bazel file
196
-
load("@doxygen//:doxygen.bzl", "doxygen")
197
-
load("@rules_cc//cc:defs.bzl", "cc_library")
198
-
199
-
cc_library(
200
-
name="lib",
201
-
hdrs= ["add.h", "sub.h"],
202
-
srcs= ["add.cpp", "sub.cpp"],
203
-
)
204
-
205
-
cc_library(
206
-
name="main",
207
-
srcs= ["main.cpp"],
208
-
deps= [":lib"],
209
-
)
210
-
211
-
212
-
genrule(
213
-
name="section",
214
-
outs= ["Section.md"],
215
-
cmd="""
216
-
echo "# Section " > $@
217
-
echo "This is some amazing documentation with section!! " >> $@
218
-
echo "Incredible." >> $@
219
-
""",
220
-
)
221
-
222
-
doxygen(
223
-
name="doxygen",
224
-
project_name="dependencies",
225
-
226
-
# The output of the genrule will be included in the documentation.
227
-
# The genrule will be executed when the documentation is generated.
228
-
srcs= [
229
-
"README.md", # file
230
-
":section", # genrule
231
-
232
-
# WARNING: By adding this, the main target will be built
233
-
# and only the output file `main.o` will be passed to Doxygen,
234
-
# which is likely not what you want.
235
-
# ":main"
236
-
],
237
-
238
-
# The sources of the main target and its dependencies will be included.
239
-
# No compilation will be performed, so compile error won't be reported.
240
-
deps= [":main"], # cc_library
241
-
242
-
# Always starts at the root folder
243
-
use_mdfile_as_mainpage="dependencies/README.md",
244
-
)
245
-
```
246
-
247
184
## Build
248
185
249
186
To build the documentation, run the following command:
Copy file name to clipboardExpand all lines: docs/doxygen_doc.md
+72-5Lines changed: 72 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,6 +107,73 @@ Depending on the type of the attribute, the macro will convert it to the appropr
107
107
108
108
For the complete list of Doxygen configuration options, please refer to the [Doxygen documentation](https://www.doxygen.nl/manual/config.html).
109
109
110
+
### Differences between `srcs` and `deps`
111
+
112
+
The `srcs` and `deps` attributes work differently and are not interchangeable.
113
+
114
+
`srcs` is a list of files that will be passed to Doxygen for documentation generation.
115
+
You can use `glob` to include a collection of multiple files.
116
+
On the other hand, if you indicate a target (e.g., `:my_genrule`), it will include all the files produced by that target.
117
+
More precisely, the files in the DefaultInfo provider the target returns.
118
+
Hence, when the documentation is generated, all rules in the `srcs` attribute **will** be built, and the files they output will be passed to Doxygen.
119
+
120
+
On the other hand, `deps` is a list of targets whose sources will be included in the documentation generation.
121
+
It will automatically include all the files in the `srcs`, `hdrs`, and `data` attributes of the target, and the same applies to all of its transitive dependencies, recursively.
122
+
Since we are only interested in the source files, the `deps` targets **will not** be built when the documentation is generated.
123
+
124
+
```bzl
125
+
# My BUILD.bazel file
126
+
load("@doxygen//:doxygen.bzl", "doxygen")
127
+
load("@rules_cc//cc:defs.bzl", "cc_library")
128
+
129
+
cc_library(
130
+
name="lib",
131
+
hdrs= ["add.h", "sub.h"],
132
+
srcs= ["add.cpp", "sub.cpp"],
133
+
)
134
+
135
+
cc_library(
136
+
name="main",
137
+
srcs= ["main.cpp"],
138
+
deps= [":lib"],
139
+
)
140
+
141
+
142
+
genrule(
143
+
name="section",
144
+
outs= ["Section.md"],
145
+
cmd="""
146
+
echo "# Section " > $@
147
+
echo "This is some amazing documentation with section!! " >> $@
148
+
echo "Incredible." >> $@
149
+
""",
150
+
)
151
+
152
+
doxygen(
153
+
name="doxygen",
154
+
project_name="dependencies",
155
+
156
+
# The output of the genrule will be included in the documentation.
157
+
# The genrule will be executed when the documentation is generated.
158
+
srcs= [
159
+
"README.md", # file
160
+
":section", # genrule
161
+
162
+
# WARNING: By adding this, the main target will be built
163
+
# and only the output files `libmain.so` and `libmain.a`
164
+
# will be passed to Doxygen, which is likely not what you want.
165
+
# ":main"
166
+
],
167
+
168
+
# The sources of the main target and its dependencies will be included.
169
+
# No compilation will be performed, so compile error won't be reported.
| <aid="doxygen-name"></a>name |A name for the target. | none |
159
-
| <aid="doxygen-srcs"></a>srcs |A list of source files to generate documentation for. |`[]`|
160
-
| <aid="doxygen-deps"></a>deps |A list of dependencies whose source, header and data files, and those or the transitive dependencies, will be included in the documentation. |`[]`|
225
+
| <aid="doxygen-name"></a>name |Name for the target. | none |
226
+
| <aid="doxygen-srcs"></a>srcs |List of source files to generate documentation for. Can include any file that Doxygen can parse, as well as targets that return a DefaultInfo provider (usually genrules). Since we are only considering the outputs files and not the sources, these targets **will** be built if necessary. |`[]`|
227
+
| <aid="doxygen-deps"></a>deps |List of dependencies targets whose files present in the 'src', 'hdrs' and 'data' attributes will be collected to generate the documentation. Transitive dependencies are also taken into account. Since we are only considering the source files and not the outputs, these targets **will not** be built. |`[]`|
161
228
| <aid="doxygen-dot_executable"></a>dot_executable | Label of the doxygen executable. Make sure it is also added to the `srcs` of the macro |`None`|
162
-
| <aid="doxygen-configurations"></a>configurations |A list of additional configuration parameters to pass to Doxygen. |`None`|
229
+
| <aid="doxygen-configurations"></a>configurations |List of additional configuration parameters to pass to Doxygen. |`None`|
163
230
| <aid="doxygen-doxyfile_template"></a>doxyfile_template | The template file to use to generate the Doxyfile. The following substitutions are available:<br> - `# {{INPUT}}`: Subpackage directory in the sandbox.<br> - `# {{ADDITIONAL PARAMETERS}}`: Additional parameters given in the `configurations` attribute.<br> - `# {{OUTPUT DIRECTORY}}`: The directory provided in the `outs` attribute. |`None`|
164
231
| <aid="doxygen-doxygen_extra_args"></a>doxygen_extra_args | Extra arguments to pass to the doxygen executable. |`[]`|
165
-
| <aid="doxygen-outs"></a>outs |The output folders bazel will keep. If only the html outputs is of interest, the default value will do. otherwise, a list of folders to keep is expected (e.g. ["html", "latex"]). Note that the rule will also generate an output group for each folder in the outs list having the same name. |`["html"]`|
232
+
| <aid="doxygen-outs"></a>outs |Output folders bazel will keep. If only the html outputs is of interest, the default value will do. otherwise, a list of folders to keep is expected (e.g. ["html", "latex"]). Note that the rule will also generate an output group for each folder in the outs list having the same name. |`["html"]`|
166
233
| <aid="doxygen-doxyfile_encoding"></a>doxyfile_encoding | This tag specifies the encoding used for all characters in the configuration file that follow. |`None`|
167
234
| <aid="doxygen-project_name"></a>project_name | The `project_name` tag is a single word (or a sequence of words surrounded by double-quotes, unless you are using Doxywizard) that should identify the project for which the documentation is generated. |`None`|
168
235
| <aid="doxygen-project_number"></a>project_number | The `project_number` tag can be used to enter a project or revision number. |`None`|
Copy file name to clipboardExpand all lines: doxygen/doxygen.bzl
+67Lines changed: 67 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -496,6 +496,73 @@ def doxygen(
496
496
497
497
For the complete list of Doxygen configuration options, please refer to the [Doxygen documentation](https://www.doxygen.nl/manual/config.html).
498
498
499
+
### Differences between `srcs` and `deps`
500
+
501
+
The `srcs` and `deps` attributes work differently and are not interchangeable.
502
+
503
+
`srcs` is a list of files that will be passed to Doxygen for documentation generation.
504
+
You can use `glob` to include a collection of multiple files.
505
+
On the other hand, if you indicate a target (e.g., `:my_genrule`), it will include all the files produced by that target.
506
+
More precisely, the files in the DefaultInfo provider the target returns.
507
+
Hence, when the documentation is generated, all rules in the `srcs` attribute **will** be built, and the files they output will be passed to Doxygen.
508
+
509
+
On the other hand, `deps` is a list of targets whose sources will be included in the documentation generation.
510
+
It will automatically include all the files in the `srcs`, `hdrs`, and `data` attributes of the target, and the same applies to all of its transitive dependencies, recursively.
511
+
Since we are only interested in the source files, the `deps` targets **will not** be built when the documentation is generated.
512
+
513
+
```bzl
514
+
# My BUILD.bazel file
515
+
load("@doxygen//:doxygen.bzl", "doxygen")
516
+
load("@rules_cc//cc:defs.bzl", "cc_library")
517
+
518
+
cc_library(
519
+
name = "lib",
520
+
hdrs = ["add.h", "sub.h"],
521
+
srcs = ["add.cpp", "sub.cpp"],
522
+
)
523
+
524
+
cc_library(
525
+
name = "main",
526
+
srcs = ["main.cpp"],
527
+
deps = [":lib"],
528
+
)
529
+
530
+
531
+
genrule(
532
+
name = "section",
533
+
outs = ["Section.md"],
534
+
cmd = \"\"\"
535
+
echo "# Section " > $@
536
+
echo "This is some amazing documentation with section!! " >> $@
537
+
echo "Incredible." >> $@
538
+
\"\"\",
539
+
)
540
+
541
+
doxygen(
542
+
name = "doxygen",
543
+
project_name = "dependencies",
544
+
545
+
# The output of the genrule will be included in the documentation.
546
+
# The genrule will be executed when the documentation is generated.
547
+
srcs = [
548
+
"README.md", # file
549
+
":section", # genrule
550
+
551
+
# WARNING: By adding this, the main target will be built
552
+
# and only the output files `libmain.so` and `libmain.a`
553
+
# will be passed to Doxygen, which is likely not what you want.
554
+
# ":main"
555
+
],
556
+
557
+
# The sources of the main target and its dependencies will be included.
558
+
# No compilation will be performed, so compile error won't be reported.
0 commit comments