Skip to content

Commit 6838cc8

Browse files
committed
docs: move detailed documentation in separate file
1 parent ec68cb9 commit 6838cc8

File tree

3 files changed

+143
-72
lines changed

3 files changed

+143
-72
lines changed

README.md

Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -171,79 +171,16 @@ doxygen(
171171
)
172172
```
173173

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+
174178
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.
175179
They will simply be appended at the end of the file, overriding the default values.
176180

177181
> [!Note]
178182
> See the [documentation](docs/doxygen_doc.md) for more information or the [examples](examples) directory for examples of how to use the rules.
179183
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-
247184
## Build
248185

249186
To build the documentation, run the following command:

docs/doxygen_doc.md

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,73 @@ Depending on the type of the attribute, the macro will convert it to the appropr
107107

108108
For the complete list of Doxygen configuration options, please refer to the [Doxygen documentation](https://www.doxygen.nl/manual/config.html).
109109

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.
170+
deps = [":main"], # cc_library
171+
172+
# Always starts at the root folder
173+
use_mdfile_as_mainpage = "dependencies/README.md",
174+
)
175+
```
176+
110177
### Example
111178

112179
```bzl
@@ -155,14 +222,14 @@ doxygen(
155222

156223
| Name | Description | Default Value |
157224
| :------------- | :------------- | :------------- |
158-
| <a id="doxygen-name"></a>name | A name for the target. | none |
159-
| <a id="doxygen-srcs"></a>srcs | A list of source files to generate documentation for. | `[]` |
160-
| <a id="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+
| <a id="doxygen-name"></a>name | Name for the target. | none |
226+
| <a id="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+
| <a id="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. | `[]` |
161228
| <a id="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-
| <a id="doxygen-configurations"></a>configurations | A list of additional configuration parameters to pass to Doxygen. | `None` |
229+
| <a id="doxygen-configurations"></a>configurations | List of additional configuration parameters to pass to Doxygen. | `None` |
163230
| <a id="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` |
164231
| <a id="doxygen-doxygen_extra_args"></a>doxygen_extra_args | Extra arguments to pass to the doxygen executable. | `[]` |
165-
| <a id="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+
| <a id="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"]` |
166233
| <a id="doxygen-doxyfile_encoding"></a>doxyfile_encoding | This tag specifies the encoding used for all characters in the configuration file that follow. | `None` |
167234
| <a id="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` |
168235
| <a id="doxygen-project_number"></a>project_number | The `project_number` tag can be used to enter a project or revision number. | `None` |

doxygen/doxygen.bzl

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,73 @@ def doxygen(
496496
497497
For the complete list of Doxygen configuration options, please refer to the [Doxygen documentation](https://www.doxygen.nl/manual/config.html).
498498
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.
559+
deps = [":main"], # cc_library
560+
561+
# Always starts at the root folder
562+
use_mdfile_as_mainpage = "dependencies/README.md",
563+
)
564+
```
565+
499566
### Example
500567
501568
```bzl

0 commit comments

Comments
 (0)