You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "vincbeck (via GitHub)" <gi...@apache.org> on 2023/06/08 15:04:56 UTC

[GitHub] [airflow-site] vincbeck commented on a diff in pull request #794: Building framework to allow multiple types of back referencing docs

vincbeck commented on code in PR #794:
URL: https://github.com/apache/airflow-site/pull/794#discussion_r1223178005


##########
post-docs/README.md:
##########
@@ -0,0 +1,9 @@
+# Post Documentation Process
+
+In order to support backward compatibility of the documentation generation process, this additional step is needed to add refresh HTMLs for older released docs.
+The issue persists across helm, provider, and regular airflow docs.
+
+To generate these back referencing(refresh HTMLs), run the script in the following manner:

Review Comment:
   ```suggestion
   To generate these back referencing (refresh HTMLs), run the script in the following manner:
   ```



##########
post-docs/add-back-references.py:
##########
@@ -76,30 +88,49 @@ def create_back_reference_html(back_ref_url, path):
         f.write(content)
 
 
-download_file(docs_link)
-old_to_new = construct_mapping()
-
-versions = [f.path.split("/")[-1] for f in os.scandir(apache_airflow_path) if f.is_dir()]
-versions = [v for v in versions if version_is_less_than(v)]
-
-for version in versions:
-    r = apache_airflow_path + "/" + version
-
-    for p in old_to_new:
-        old = p
-        new = old_to_new[p]
-
-        # only if old file exists, add the back reference
-        if os.path.exists(r + "/" + p):
-            d = old_to_new[p].split("/")
-            file_name = old_to_new[p].split("/")[-1]
-            dest_dir = r + "/" + "/".join(d[: len(d) - 1])
-
-            # finds relative path of old file wrt new, handles case of different file names too
-            relative_path = os.path.relpath(old, new)
-            # remove one directory level because file path was used above
-            relative_path = relative_path.replace("../", "", 1)
-
-            os.makedirs(dest_dir, exist_ok=True)
-            dest_file_path = dest_dir + "/" + file_name
-            create_back_reference_html(relative_path, dest_file_path)
+def generate_back_references(link, base_path, change_version):
+    download_file(link)
+    old_to_new = construct_mapping()
+
+    versions = [f.path.split("/")[-1] for f in os.scandir(base_path) if f.is_dir()]
+    versions = [v for v in versions if version_is_less_than(v, change_version)]
+
+    for version in versions:
+        r = base_path + "/" + version
+
+        for p in old_to_new:
+            old = p
+            new = old_to_new[p]
+
+            # only if old file exists, add the back reference
+            if os.path.exists(r + "/" + p):
+                d = old_to_new[p].split("/")
+                file_name = old_to_new[p].split("/")[-1]
+                dest_dir = r + "/" + "/".join(d[: len(d) - 1])
+
+                # finds relative path of old file wrt new, handles case of different file names too
+                relative_path = os.path.relpath(old, new)
+                # remove one directory level because file path was used above
+                relative_path = relative_path.replace("../", "", 1)
+
+                os.makedirs(dest_dir, exist_ok=True)
+                dest_file_path = dest_dir + "/" + file_name
+                create_back_reference_html(relative_path, dest_file_path)
+
+
+# total arguments
+n = len(sys.argv)
+if n != 2:
+    logging.Logger.error("missing required arguments, syntax: python add-back-references.py [airflow | providers | "
+                         "helm]")
+
+type_generation = sys.argv[1]
+if type_generation == airflow_type:
+    generate_back_references(airflow_redirects_link, airflow_docs_path, new_airflow_docs_version)
+elif type_generation == helm_type:
+    generate_back_references(helm_redirects_link, helm_docs_path, new_helm_docs_version)
+elif type_generation == provider_type:
+    pass

Review Comment:
   Is it work in progress?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org