potiuk commented on code in PR #73477:
URL: https://github.com/apache/airflow/pull/73477#discussion_r4068696229


##########
devel-common/src/sphinx_exts/airflow_intersphinx.py:
##########
@@ -22,12 +22,54 @@
 from typing import TYPE_CHECKING, Any
 
 from provider_yaml_utils import load_package_data
+from sphinx.util.inventory import InventoryFile
 
 if TYPE_CHECKING:
     from sphinx.application import Sphinx
 
 AIRFLOW_ROOT_PATH = Path(os.path.abspath(__file__)).parents[3]
 GENERATED_PATH = AIRFLOW_ROOT_PATH / "generated"
+INVENTORY_FILENAME = "objects.inv"
+
+
+def _inventory_for(package_name: str, versioned: bool) -> Path:
+    """
+    Prefer an inventory written earlier in this run, fall back to the one 
fetched from the published docs.
+
+    The html builder writes its inventory at the root of the build directory; 
a spelling-only build
+    writes one into its own output directory (see 
``_dump_inventory_after_spelling_build``, the
+    directory name mirrors ``AirflowDocsBuilder.log_spelling_output_dir``).
+    """
+    build_dir = GENERATED_PATH / "_build" / "docs" / package_name / ("stable" 
if versioned else "")
+    built_this_run = (
+        build_dir / INVENTORY_FILENAME,
+        build_dir / f"output-spelling-results-{package_name}" / 
INVENTORY_FILENAME,
+    )
+    downloaded = GENERATED_PATH / "_inventory_cache" / package_name / 
INVENTORY_FILENAME
+    return next((inventory for inventory in built_this_run if 
inventory.exists()), downloaded)
+
+
+class _HtmlTargetUris:
+    """Gives inventory entries the URIs the html build would, so the file is 
an ordinary inventory."""
+
+    @staticmethod
+    def get_target_uri(docname: str, typ: str | None = None) -> str:
+        return f"{docname}.html"
+
+
+def _dump_inventory_after_spelling_build(app: Sphinx, exception: Exception | 
None) -> None:
+    """
+    Write ``objects.inv`` after a successful spelling build.
+
+    Cross-references are resolved by every builder, so a ``--spellcheck-only`` 
run of package B fails

Review Comment:
   The problem here is that this breaks apart when:
   
   * Package B -> A and A adds new method
   * Package A has unrelated "spelling" mistake
   
   In this case (I believe) failed spellcheck build of A will **not** produce 
new inventory. As far as I know inventory is produced by spellcheck build 
**only** when it succeeds. But if there is a single spelling mistake in A - 
there will be no inventory for it (in this case the only way to get inventory A 
with new method is to run one complete build without checking spelling). 
   
   And the issue in this case is that this might lead to a completely 
misleading errors that will confuse everyone. 
   
   Package B will fail because A has no new method (which it has - but 
inventory for it has never been build). And that escalates quickly if something 
depends on package B - then you have several indirecations of misleading errors.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to