Skip to content

Commit c08384d

Browse files
AbrilRBSczoido
authored andcommitted
Make self.generator_info explicitly None by default (#4132)
1 parent 810316b commit c08384d

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

reference/conanfile/attributes/consumers.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ generator_info
102102
.. include:: ../../common/experimental_warning.inc
103103

104104
Generators to be passed to the dependant recipes.
105-
Should be only filled in the ``package_info()`` method.
105+
Should be only filled in the ``package_info()`` method, ``None`` by default.
106106

107107
.. seealso::
108108

reference/conanfile/methods/package_info.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ generator_info
306306
307307
308308
``tool_requires`` in the build context can inject generators into the recipe,
309-
by adding them to the ``generator_info`` list inside the ``package_info`` method.
309+
by adding them to the ``generator_info`` attribute inside the ``package_info`` method.
310310
This is useful to inject custom generators into the recipe, that will be used by the consumers of the package,
311311
just as if they were declared in their ``generators`` attribute.
312312
@@ -320,9 +320,10 @@ just as if they were declared in their ``generators`` attribute.
320320
self.output.info(f"Calling custom generator for {conanfile}")
321321
322322
def package_info(self):
323-
self.generator_info.append(MyGenerator)
323+
self.generator_info = [MyGenerator]
324324
325-
Note that this only propagates from the immediate, direct ``tool_requires`` of a recipe.
325+
Note that this only propagates from the immediate, direct ``tool_requires`` of a recipe,
326+
and that by default ``self.generator_info`` is ``None``.
326327
327328
328329
.. note::

reference/extensions/custom_generators.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ Generators from tool_requires
110110
A direct dependency tool requires can also be used to provide custom generators.
111111
The following example shows how to create a custom generator that generates a file with the
112112
dependencies of the package, just like the example above, but using a ``tool_require`` instead of a ``python_require``
113-
to inject the generator into the recipe, by adding them to the ``self.generator_info`` list inside the ``package_info`` method.
113+
to inject the generator into the recipe, by adding them to the ``self.generator_info`` attribute inside the ``package_info`` method.
114+
Note that this attribute is ``None`` by default, so you need to set it explicitly to a list of generators.
114115

115116
.. code-block:: python
116117
:caption: mygenerator/conanfile.py
@@ -141,6 +142,6 @@ inject the generator into the recipe.
141142
.. note::
142143

143144
Note that built-in generators can also be injected using tool_requires,
144-
by adding them by name: ``self.generator_info.append("CMakeDeps")``.
145+
by adding them by name: ``self.generator_info = ["CMakeDeps"]``.
145146
``tool_require``'ing this package will inject the ``CMakeDeps`` generator into the recipe
146147
just as if it was declared in its ``generators`` attribute.

0 commit comments

Comments
 (0)