Skip to content
Open
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
1 change: 1 addition & 0 deletions devel-common/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ dependencies = [
"sphinx-copybutton>=0.5.2",
"sphinx-design>=0.5.0",
"sphinx-jinja>=2.0.2",
"sphinx-llm>=1.1.0,<1.2", # airflow_llms_txt subclasses its Markdown translator
"sphinx-rtd-theme>=2.0.0",
"sphinx>=7",
"sphinxcontrib-applehelp>=1.0.4",
Expand Down
31 changes: 31 additions & 0 deletions devel-common/src/docs/provider_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
get_intersphinx_mapping,
get_rst_epilogue,
)
from docs.utils.example_source import example_source_ref
from sphinx_exts.provider_yaml_utils import load_package_data

PACKAGE_NAME = os.environ.get("AIRFLOW_PACKAGE_NAME", "")
Expand Down Expand Up @@ -147,6 +148,36 @@
]
)

# Providers that publish a Markdown copy of every page plus llms.txt for LLMs and coding agents.
PROVIDER_PACKAGES_WITH_LLMS_TXT = [
"apache-airflow-providers-common-ai",
]


if PACKAGE_NAME in PROVIDER_PACKAGES_WITH_LLMS_TXT:
extensions.append("airflow_llms_txt")
llms_txt_site_url = f"https://airflow.apache.org/docs/{PACKAGE_NAME}/{PACKAGE_VERSION}/"
_release_tag = f"providers-{PACKAGE_ID.replace('.', '-')}/{PACKAGE_VERSION}"
llms_txt_source_url = f"https://github.com/apache/airflow/blob/{example_source_ref(_release_tag)}/"
llms_txt_release_source_url = f"https://github.com/apache/airflow/blob/{_release_tag}/"
llms_txt_repo_root = AIRFLOW_REPO_ROOT_PATH.as_posix()
llms_txt_intro = (
f"Install with `pip install {PACKAGE_NAME}`. This index covers version {PACKAGE_VERSION}. "
"Each link is a Markdown copy of a docs page; drop the trailing `.md` for the HTML page. "
"Code samples are excerpts of example Dags, and each one links to the full file."
)
llms_txt_root_description = "Package overview, its requirements and what each optional extra installs."
# Long or generic pages an agent rarely needs first.
llms_txt_optional_docs = ["_api/**", "changelog", "security", "installing-providers-from-sources"]
# Not useful to an agent at all; their Markdown copies are still published.
llms_txt_skip_docs = ["_api/tests/**", "commits"]
llms_txt_nested_enabled = False
# One Markdown copy per page, ``page.html.md``: what llms.txt and ``rel=alternate`` link to.
llms_txt_suffix_mode = "append"
# Run the Markdown build after the HTML build, not alongside it: both run autoapi, which
# rewrites the ``_api`` sources in place while the other build may be reading them.
llms_txt_build_parallel = False
Comment thread
SameerMesiah97 marked this conversation as resolved.
Resolved

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
empty_subpackages = ["apache", "atlassian", "common", "cncf", "dbt", "ibm", "microsoft"]
Expand Down
4 changes: 3 additions & 1 deletion devel-common/src/docs/utils/conf_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def get_rst_epilogue(package_version: str, airflow_core: bool) -> str:
)


SMARTQUOTES_EXCLUDES = {"builders": ["man", "text", "spelling"]}
# ``llms-markdown`` is sphinx-llm's Markdown build: its files are served without a charset, so
# curly quotes in them turn into mojibake for clients that default ``text/*`` to Latin-1.
SMARTQUOTES_EXCLUDES = {"builders": ["man", "text", "spelling", "llms-markdown"]}

BASIC_SPHINX_EXTENSIONS = [
"sphinx.ext.autodoc",
Expand Down
46 changes: 46 additions & 0 deletions devel-common/src/docs/utils/example_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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.

from __future__ import annotations

import subprocess

from docs.utils.conf_constants import AIRFLOW_REPO_ROOT_PATH


def example_source_ref(tag: str) -> str:
"""Return HEAD if a remote-tracking ref or tag contains it; otherwise return the release tag."""
Comment thread
SameerMesiah97 marked this conversation as resolved.
Resolved

def git(*args: str) -> str:
try:
result = subprocess.run(
["git", *args], cwd=AIRFLOW_REPO_ROOT_PATH, capture_output=True, text=True, check=False
)
except OSError: # Git may be unavailable when building from an sdist.
return ""
return result.stdout.strip()

head = git("rev-parse", "--verify", "--quiet", "HEAD^{commit}")
if not head or head == git("rev-parse", "--verify", "--quiet", f"{tag}^{{commit}}"):
return tag

# Main docs may reference examples missing from the latest release tag.
# The docs publishing workflow can cherry-pick fixes onto a release tag,
# creating a local-only HEAD that is unavailable on GitHub. Prefer HEAD
# when a remote-tracking ref or tag contains it; otherwise use the release tag.
pushed = git("for-each-ref", "--contains", head, "--count=1", "refs/remotes", "refs/tags")
return head if pushed else tag
Loading