Skip to content

Commit 9717d44

Browse files
huonwWorkerPants
authored andcommitted
Update doc_url calls for new website (#20583)
This PR fixes #20427 by updating our use of `doc_url` to reflect the new website structure. It does this semi-automatically, spread across separate commits: 1. Update the `doc_url` function to reflect the new website structure, including support for unversioned URLs like https://www.pantsbuild.org/community/getting-help 2. Apply automated rewrites (see below for details) 3. Do one or two manual fix-ups The automatic rewrites were done by: 1. finding the args passed to `doc_url`: `rg --only-matching "doc_url\([^)]*\)" . | cut -f2 -d\( | cut -f1 -d\) | tr \' \" | sort -u` 2. put them into CSV file, then use https://github.com/pantsbuild/pantsbuild.org/blob/92d5ce8d3442890c3fbeb0fade620b762ae2aa7e/old_site_redirects.js to find the new URL for each one 3. transform the CSV into a long series of `s@...@...@` substitutions for `sed` 4. apply them with `git ls-files '*.py' '*.rs' | xargs sed -i '' "..."` 5. do a basic check that the appropriate files that call `doc_url` were updated: identify non-updated files via `comm -13 <(git diff --name-only be42bc0^...be42bc0) <( rg --files-with-matches doc_url | sort)`. The files without updates are expected, e.g. - `src/python/pants/util/docutil.py` that defines `doc_url` itself (and the test file etc.) - `src/python/pants/backend/codegen/avro/target_types.py` that didn't have an immediately obvious replacement, with more examples in #20584 This is marked for cherry-picking to 2.20.x. There _are_ redirects for the URLs for 2.20, but it seems a bit annoying to rely on them, if we don't have to. <details> ```csv old,new "getting-help","community/getting-help" "advanced-target-selection","docs/using-pants/advanced-target-selection" "anonymous-telemetry","docs/using-pants/anonymous-telemetry" "awslambda-python","docs/python/integrations/aws-lambda" "enabling-backends","docs/using-pants/key-concepts/backends" "google-cloud-function-python","docs/python/integrations/google-cloud-functions" "installation","docs/getting-started/installing-pants" "macros","docs/writing-plugins/macros" "options","docs/using-pants/key-concepts/options" "options#addremove-semantics","docs/using-pants/key-concepts/options#addremove-semantics" "options#config-file-entries","docs/using-pants/key-concepts/options#config-file-entries" "options#config-file-interpolation","docs/using-pants/key-concepts/options#config-file-interpolation" "options#pantsrc-file","docs/using-pants/key-concepts/options#pantsrc-file" "options#reading-individual-option-values-from-files","docs/using-pants/key-concepts/options#reading-individual-option-values-from-files" "pex","docs/python/overview/pex" "plugin-upgrade-guide","docs/writing-plugins/common-plugin-tasks/plugin-upgrade-guide" "plugins-overview","docs/writing-plugins/overview" "plugins-setup-py","docs/writing-plugins/common-plugin-tasks/custom-python-artifact-kwargs" "protobuf-go","docs/go/integrations/protobuf" "protobuf-python","docs/python/integrations/protobuf-and-grpc" "python-check-goal","docs/python/goals/check" "python-distributions","docs/python/overview/building-distributions" "python-interpreter-compatibility","docs/python/overview/interpreter-compatibility" "python-lockfiles#lockfiles-for-tools","docs/python/overview/lockfiles#lockfiles-for-tools" "python-test-goal","docs/python/goals/test" "python-test-goal#pytest-version-and-plugins","docs/python/goals/test#pytest-version-and-plugins" "python-third-party-dependencies","docs/python/overview/third-party-dependencies" "python-third-party-dependencies#local-requirements","docs/python/overview/third-party-dependencies#local-requirements" "python-third-party-dependencies#multiple-lockfiles","docs/python/overview/lockfiles#multiple-lockfiles" "python-third-party-dependencies#user-lockfiles","docs/python/overview/third-party-dependencies#user-lockfiles" "reference-deploy_jar#coderesolvecode","reference/targets/deploy_jar#resolve" "reference-global#remote_oauth_bearer_token","reference/global-options#remote_oauth_bearer_token" "remote-caching-execution","docs/using-pants/remote-caching-and-execution" "source-roots","docs/using-pants/key-concepts/source-roots" "tagging-docker-images","docs/docker/tagging-docker-images" "target-api-concepts","docs/writing-plugins/the-target-api/concepts" "targets","docs/using-pants/key-concepts/targets-and-build-files" "targets#field-default-values","docs/using-pants/key-concepts/targets-and-build-files#field-default-values" "targets#dependencies-and-dependency-inference","docs/using-pants/key-concepts/targets-and-build-files#dependencies-and-dependency-inference" "thrift-python","docs/python/integrations/thrift" "troubleshooting","docs/using-pants/troubleshooting-common-issues" "troubleshooting#import-errors-and-missing-dependencies","docs/using-pants/troubleshooting-common-issues#import-errors-and-missing-dependencies" "upgrade-tips","docs/releases/upgrade-tips" ``` ```python import pandas as pd print("\n".join( f"""s@\\(doc_url.*[\\"']\\){r.old}\\([\\"']\\)@\\1{r.new}\\2@g;""" for _, r in pd.read_csv("replacements.csv").iterrows() )) ``` ```shell git ls-files '*.py' '*.rs' | xargs sed -i '' " s@\(doc_url.*[\"']\)getting-help\([\"']\)@\1community/getting-help\2@g; s@\(doc_url.*[\"']\)advanced-target-selection\([\"']\)@\1docs/using-pants/advanced-target-selection\2@g; s@\(doc_url.*[\"']\)anonymous-telemetry\([\"']\)@\1docs/using-pants/anonymous-telemetry\2@g; s@\(doc_url.*[\"']\)awslambda-python\([\"']\)@\1docs/python/integrations/aws-lambda\2@g; s@\(doc_url.*[\"']\)enabling-backends\([\"']\)@\1docs/using-pants/key-concepts/backends\2@g; s@\(doc_url.*[\"']\)google-cloud-function-python\([\"']\)@\1docs/python/integrations/google-cloud-functions\2@g; s@\(doc_url.*[\"']\)installation\([\"']\)@\1docs/getting-started/installing-pants\2@g; s@\(doc_url.*[\"']\)macros\([\"']\)@\1docs/writing-plugins/macros\2@g; s@\(doc_url.*[\"']\)options\([\"']\)@\1docs/using-pants/key-concepts/options\2@g; s@\(doc_url.*[\"']\)options#addremove-semantics\([\"']\)@\1docs/using-pants/key-concepts/options#addremove-semantics\2@g; s@\(doc_url.*[\"']\)options#config-file-entries\([\"']\)@\1docs/using-pants/key-concepts/options#config-file-entries\2@g; s@\(doc_url.*[\"']\)options#config-file-interpolation\([\"']\)@\1docs/using-pants/key-concepts/options#config-file-interpolation\2@g; s@\(doc_url.*[\"']\)options#pantsrc-file\([\"']\)@\1docs/using-pants/key-concepts/options#pantsrc-file\2@g; s@\(doc_url.*[\"']\)options#reading-individual-option-values-from-files\([\"']\)@\1docs/using-pants/key-concepts/options#reading-individual-option-values-from-files\2@g; s@\(doc_url.*[\"']\)pex\([\"']\)@\1docs/python/overview/pex\2@g; s@\(doc_url.*[\"']\)plugin-upgrade-guide\([\"']\)@\1docs/writing-plugins/common-plugin-tasks/plugin-upgrade-guide\2@g; s@\(doc_url.*[\"']\)plugins-overview\([\"']\)@\1docs/writing-plugins/overview\2@g; s@\(doc_url.*[\"']\)plugins-setup-py\([\"']\)@\1docs/writing-plugins/common-plugin-tasks/custom-python-artifact-kwargs\2@g; s@\(doc_url.*[\"']\)protobuf-go\([\"']\)@\1docs/go/integrations/protobuf\2@g; s@\(doc_url.*[\"']\)protobuf-python\([\"']\)@\1docs/python/integrations/protobuf-and-grpc\2@g; s@\(doc_url.*[\"']\)python-check-goal\([\"']\)@\1docs/python/goals/check\2@g; s@\(doc_url.*[\"']\)python-distributions\([\"']\)@\1docs/python/overview/building-distributions\2@g; s@\(doc_url.*[\"']\)python-interpreter-compatibility\([\"']\)@\1docs/python/overview/interpreter-compatibility\2@g; s@\(doc_url.*[\"']\)python-lockfiles#lockfiles-for-tools\([\"']\)@\1docs/python/overview/lockfiles#lockfiles-for-tools\2@g; s@\(doc_url.*[\"']\)python-test-goal\([\"']\)@\1docs/python/goals/test\2@g; s@\(doc_url.*[\"']\)python-test-goal#pytest-version-and-plugins\([\"']\)@\1docs/python/goals/test#pytest-version-and-plugins\2@g; s@\(doc_url.*[\"']\)python-third-party-dependencies\([\"']\)@\1docs/python/overview/third-party-dependencies\2@g; s@\(doc_url.*[\"']\)python-third-party-dependencies#local-requirements\([\"']\)@\1docs/python/overview/third-party-dependencies#local-requirements\2@g; s@\(doc_url.*[\"']\)python-third-party-dependencies#multiple-lockfiles\([\"']\)@\1docs/python/overview/lockfiles#multiple-lockfiles\2@g; s@\(doc_url.*[\"']\)python-third-party-dependencies#user-lockfiles\([\"']\)@\1docs/python/overview/third-party-dependencies#user-lockfiles\2@g; s@\(doc_url.*[\"']\)reference-deploy_jar#coderesolvecode\([\"']\)@\1reference/targets/deploy_jar#resolve\2@g; s@\(doc_url.*[\"']\)reference-global#remote_oauth_bearer_token\([\"']\)@\1reference/global-options#remote_oauth_bearer_token\2@g; s@\(doc_url.*[\"']\)remote-caching-execution\([\"']\)@\1docs/using-pants/remote-caching-and-execution\2@g; s@\(doc_url.*[\"']\)source-roots\([\"']\)@\1docs/using-pants/key-concepts/source-roots\2@g; s@\(doc_url.*[\"']\)tagging-docker-images\([\"']\)@\1docs/docker/tagging-docker-images\2@g; s@\(doc_url.*[\"']\)target-api-concepts\([\"']\)@\1docs/writing-plugins/the-target-api/concepts\2@g; s@\(doc_url.*[\"']\)targets\([\"']\)@\1docs/using-pants/key-concepts/targets-and-build-files\2@g; s@\(doc_url.*[\"']\)targets#field-default-values\([\"']\)@\1docs/using-pants/key-concepts/targets-and-build-files#field-default-values\2@g; s@\(doc_url.*[\"']\)targets#dependencies-and-dependency-inference\([\"']\)@\1docs/using-pants/key-concepts/targets-and-build-files#dependencies-and-dependency-inference\2@g; s@\(doc_url.*[\"']\)thrift-python\([\"']\)@\1docs/python/integrations/thrift\2@g; s@\(doc_url.*[\"']\)troubleshooting\([\"']\)@\1docs/using-pants/troubleshooting-common-issues\2@g; s@\(doc_url.*[\"']\)troubleshooting#import-errors-and-missing-dependencies\([\"']\)@\1docs/using-pants/troubleshooting-common-issues#import-errors-and-missing-dependencies\2@g; s@\(doc_url.*[\"']\)upgrade-tips\([\"']\)@\1docs/releases/upgrade-tips\2@g; " ``` </details>
1 parent be760d0 commit 9717d44

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+122
-88
lines changed

src/python/pants/backend/awslambda/python/target_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class PythonAWSLambda(_AWSLambdaBaseTarget):
191191
f"""
192192
A self-contained Python function suitable for uploading to AWS Lambda.
193193
194-
See {doc_url('awslambda-python')}.
194+
See {doc_url('docs/python/integrations/aws-lambda')}.
195195
"""
196196
)
197197

@@ -207,7 +207,7 @@ class PythonAWSLambdaLayer(_AWSLambdaBaseTarget):
207207
f"""
208208
A Python layer suitable for uploading to AWS Lambda.
209209
210-
See {doc_url('awslambda-python')}.
210+
See {doc_url('docs/python/integrations/aws-lambda')}.
211211
"""
212212
)
213213

src/python/pants/backend/codegen/protobuf/python/python_protobuf_subsystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PythonProtobufSubsystem(Subsystem):
3535
f"""
3636
Options related to the Protobuf Python backend.
3737
38-
See {doc_url('protobuf-python')}.
38+
See {doc_url('docs/python/integrations/protobuf-and-grpc')}.
3939
"""
4040
)
4141

src/python/pants/backend/codegen/protobuf/target_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class ProtobufSourceTarget(Target):
6666
A single Protobuf file used to generate various languages.
6767
6868
See language-specific docs:
69-
Python: {doc_url('protobuf-python')}
70-
Go: {doc_url('protobuf-go')}
69+
Python: {doc_url('docs/python/integrations/protobuf-and-grpc')}
70+
Go: {doc_url('docs/go/integrations/protobuf')}
7171
"""
7272
)
7373

src/python/pants/backend/codegen/thrift/target_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ThriftSourceTarget(Target):
7272
A single Thrift file used to generate various languages.
7373
7474
See language-specific docs:
75-
Python: {doc_url('thrift-python')}
75+
Python: {doc_url('docs/python/integrations/thrift')}
7676
"""
7777
)
7878

src/python/pants/backend/codegen/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def find_python_runtime_library_or_raise_error(
5454
No `python_requirement` target was found with the module `{runtime_library_module}`
5555
in your project{for_resolve_str}, so the Python code generated from the target
5656
{codegen_address} will not work properly. See
57-
{doc_url('python-third-party-dependencies')} for how to add a requirement, such as
57+
{doc_url('docs/python/overview/third-party-dependencies')} for how to add a requirement, such as
5858
adding to requirements.txt. Usually you will want to use the
5959
`{recommended_requirement_name}` project at {recommended_requirement_url}.
6060

src/python/pants/backend/docker/target_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class DockerImageTagsField(StringSequenceField):
149149
150150
{_interpolation_help.format(kind="tag")}
151151
152-
See {doc_url('tagging-docker-images')}.
152+
See {doc_url('docs/docker/tagging-docker-images')}.
153153
"""
154154
)
155155

src/python/pants/backend/google_cloud_function/python/target_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class PythonGoogleCloudFunction(Target):
125125
f"""
126126
A self-contained Python function suitable for uploading to Google Cloud Function.
127127
128-
See {doc_url('google-cloud-function-python')}.
128+
See {doc_url('docs/python/integrations/google-cloud-functions')}.
129129
"""
130130
)
131131

src/python/pants/backend/python/dependency_inference/rules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ async def _handle_unowned_imports(
346346
347347
If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the
348348
import line. Otherwise, see
349-
{doc_url('troubleshooting#import-errors-and-missing-dependencies')} for common problems.
349+
{doc_url('docs/using-pants/troubleshooting-common-issues#import-errors-and-missing-dependencies')} for common problems.
350350
"""
351351
)
352352
if unowned_dependency_behavior is UnownedDependencyUsage.LogWarning:

src/python/pants/backend/python/goals/pytest_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ async def validate_pytest_cov_included(_pytest: PyTest):
243243
`{_pytest.install_from_resolve}` used to install pytest is missing
244244
`pytest-cov`, which is needed to collect coverage data.
245245
246-
See {doc_url("python-test-goal#pytest-version-and-plugins")} for details
246+
See {doc_url("docs/python/goals/test#pytest-version-and-plugins")} for details
247247
on how to set up a custom resolve for use by pytest.
248248
"""
249249
)

src/python/pants/backend/python/goals/repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def maybe_get_resolve(t: Target) -> str | None:
5454
raise NoCompatibleResolveException.bad_input_roots(
5555
root_targets,
5656
maybe_get_resolve=maybe_get_resolve,
57-
doc_url_slug="python-third-party-dependencies#multiple-lockfiles",
57+
doc_url_slug="docs/python/overview/lockfiles#multiple-lockfiles",
5858
workaround=softwrap(
5959
f"""
6060
To work around this, choose which resolve you want to use from above. Then, run

0 commit comments

Comments
 (0)