Skip to content

More docs on generators #3887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions reference/conanfile/attributes/consumers.inc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ Should be only filled in the ``package_info()`` method.
Read here :ref:`the complete reference of self.conf_info <conan_conanfile_model_conf_info>`.


generators_info
---------------

.. include:: ../../common/experimental_warning.inc

Generators to be passed to the dependant recipes.
Should be only filled in the ``package_info()`` method.

.. seealso::

See :ref:`an example usage here <reference_commands_custom_generators_tool_requires>`
and :ref:`the complete reference of self.generators_info <conan_conanfile_model_generators_info>`.

deprecated
----------

Expand Down
27 changes: 27 additions & 0 deletions reference/conanfile/methods/package_info.rst
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,33 @@ configuration as:
Note that this only propagates from the immediate, direct ``tool_requires`` of a recipe.
.. _conan_conanfile_model_generators_info:
generators_info
---------------
.. include:: ../../../common/experimental_warning.inc
``tool_requires`` in the build context can inject generators into the recipe,
by adding them to the ``generators_info`` list inside the ``package_info`` method.
This is useful to inject custom generators into the recipe, that will be used by the consumers of the package,
just as if they were declared in their ``generators`` attribute.
.. code-block:: python
class MyGenerator:
def __init__(self, conanfile):
self._conanfile = conanfile
def generate(self):
self.output.info(f"Calling custom generator for {conanfile}")
def package_info(self):
self.generators_info.append(MyGenerator)
Note that this only propagates from the immediate, direct ``tool_requires`` of a recipe.
.. note::
Expand Down
2 changes: 2 additions & 0 deletions reference/extensions/custom_generators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ argument:
conan install --requires=zlib/1.2.13 -g MyGenerator
.. _reference_commands_custom_generators_tool_requires:

Generators from tool_requires
-----------------------------

Expand Down