def builder_inited(app):
    """Run during Sphinx `builder-inited` phase.

    Set a config value to builder name and add module docs to `docs_to_remove`.
    """
    print(f'The builder is: {app.builder.name}')
    app.add_config_value('builder', app.builder.name, 'env')

    # Remove pages when builder matches any referenced in exclude_from_builder
    if exclude_from_builder.get(app.builder.name):
        _docs_to_remove.extend(exclude_from_builder[app.builder.name])
Run during Sphinx `builder-inited` phase.

    Set a config value to builder name and add module docs to `docs_to_remove`.
    
docs/conf.py