This is an automated email from the ASF dual-hosted git repository.

vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 18d2498e44 Generate doc for fab CLI commands (#36672)
18d2498e44 is described below

commit 18d2498e44b58f8cfbc24e2b3beaa3b7cc7c187f
Author: Vincent <[email protected]>
AuthorDate: Thu Jan 11 17:03:24 2024 -0500

    Generate doc for fab CLI commands (#36672)
---
 .../providers/fab/auth_manager/fab_auth_manager.py | 13 ++++++++++
 docs/apache-airflow-providers-fab/cli-ref.rst      | 29 ++++++++++++++++++++++
 docs/apache-airflow-providers-fab/index.rst        |  9 ++++++-
 3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/airflow/providers/fab/auth_manager/fab_auth_manager.py 
b/airflow/providers/fab/auth_manager/fab_auth_manager.py
index 8d6d982a77..76d910eead 100644
--- a/airflow/providers/fab/auth_manager/fab_auth_manager.py
+++ b/airflow/providers/fab/auth_manager/fab_auth_manager.py
@@ -17,6 +17,7 @@
 # under the License.
 from __future__ import annotations
 
+import argparse
 from functools import cached_property
 from pathlib import Path
 from typing import TYPE_CHECKING, Container
@@ -39,6 +40,7 @@ from airflow.auth.managers.models.resource_details import (
 )
 from airflow.auth.managers.utils.fab import get_fab_action_from_method_map, 
get_method_from_fab_action_map
 from airflow.cli.cli_config import (
+    DefaultHelpParser,
     GroupCommand,
 )
 from airflow.configuration import conf
@@ -503,3 +505,14 @@ class FabAuthManager(BaseAuthManager):
             "fab", "UPDATE_FAB_PERMS", fallback=conf.getboolean("webserver", 
"UPDATE_FAB_PERMS")
         ):
             self.security_manager.sync_roles()
+
+
+def get_parser() -> argparse.ArgumentParser:
+    """Generate documentation; used by Sphinx argparse."""
+    from airflow.cli.cli_parser import AirflowHelpFormatter, _add_command
+
+    parser = DefaultHelpParser(prog="airflow", 
formatter_class=AirflowHelpFormatter)
+    subparsers = parser.add_subparsers(dest="subcommand", 
metavar="GROUP_OR_COMMAND")
+    for group_command in FabAuthManager.get_cli_commands():
+        _add_command(subparsers, group_command)
+    return parser
diff --git a/docs/apache-airflow-providers-fab/cli-ref.rst 
b/docs/apache-airflow-providers-fab/cli-ref.rst
new file mode 100644
index 0000000000..bd980f8a1e
--- /dev/null
+++ b/docs/apache-airflow-providers-fab/cli-ref.rst
@@ -0,0 +1,29 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+ ..   http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+FAB CLI Commands
+================
+
+.. note::
+   The CLI commands below are sourced from the FAB provider by Airflow 2.9.0+.
+   Previously, they were part of core Airflow, so if you are using Airflow 
below 2.9.0 please see
+   the core Airflow documentation for the list of CLI commands and parameters 
available.
+
+.. argparse::
+   :module: airflow.providers.fab.auth_manager.fab_auth_manager
+   :func: get_parser
+   :prog: airflow
diff --git a/docs/apache-airflow-providers-fab/index.rst 
b/docs/apache-airflow-providers-fab/index.rst
index dea679a69c..2702cd0239 100644
--- a/docs/apache-airflow-providers-fab/index.rst
+++ b/docs/apache-airflow-providers-fab/index.rst
@@ -34,7 +34,6 @@
     :maxdepth: 1
     :caption: Guides
 
-    Configuration <configurations-ref>
     Auth manager <auth-manager/index>
 
 .. toctree::
@@ -43,6 +42,14 @@
 
     Stable REST API <stable-rest-api-ref>
 
+.. toctree::
+    :hidden:
+    :maxdepth: 1
+    :caption: References
+
+    Configuration <configurations-ref>
+    CLI <cli-ref>
+
 .. toctree::
     :hidden:
     :maxdepth: 1

Reply via email to