Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] Revert "[FEATURE] Checker for correct Python code snippets in documentation." #7998

Merged
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
8 changes: 0 additions & 8 deletions ci/azure-pipelines-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,6 @@ stages:
python ci/checks/check_no_line_number_snippets.py
name: LineNumberSnippetChecker


- job: name_tag_snippet_checker
condition: eq(stageDependencies.scope_check.changes.outputs['CheckChanges.DocsChanged'], true)
steps:
- script: |
python ci/checks/check_only_name_tag_snippets.py
name: NameTagSnippetChecker

- job: public_api_report
steps:
- script: |
Expand Down
8 changes: 0 additions & 8 deletions ci/azure-pipelines-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ stages:
python ci/checks/check_no_line_number_snippets.py
name: LineNumberSnippetChecker


- job: name_tag_snippet_checker
condition: or(eq(stageDependencies.scope_check.changes.outputs['CheckDocsChanges.DocsChanged'], true), eq(variables.isDevelop, true), eq(variables.isManual, true))
steps:
- script: |
python ci/checks/check_only_name_tag_snippets.py
name: NameTagSnippetChecker

- job: public_api_report
condition: or(eq(stageDependencies.scope_check.changes.outputs['CheckDocsChanges.DocsChanged'], true), eq(variables.isDevelop, true), eq(variables.isManual, true))
steps:
Expand Down
7 changes: 0 additions & 7 deletions ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@ stages:
python ci/checks/check_no_line_number_snippets.py
name: LineNumberSnippetChecker

- job: name_tag_snippet_checker
condition: or(eq(variables.isScheduled, true), eq(variables.isReleasePrep, true), eq(variables.isRelease, true), eq(variables.isManual, true))
steps:
- script: |
python ci/checks/check_only_name_tag_snippets.py
name: NameTagSnippetChecker

- job: check_repo_root_size
condition: or(eq(variables.isScheduled, true), eq(variables.isReleasePrep, true), eq(variables.isRelease, true), eq(variables.isManual, true))
steps:
Expand Down
53 changes: 8 additions & 45 deletions ci/checks/check_no_line_number_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@
import sys
from typing import List

ITEMS_IGNORED_FROM_LINE_NUMBER_SNIPPET_CHECKER = {
"docs/docusaurus/node_modules/prism-react-renderer/README.md",
"docs/prepare_to_build_docs.sh",
"docs/docusaurus/node_modules/remark-code-import/index.js",
"docs/docusaurus/node_modules/remark-code-import/README.md",
"docs/prepare_prior_versions.py",
"docs/docusaurus/node_modules/open/xdg-open",
}


def check_dependencies(*deps: str) -> None:
for dep in deps:
Expand All @@ -26,61 +17,33 @@ def check_dependencies(*deps: str) -> None:

def run_grep(target_dir: pathlib.Path) -> List[str]:
try:
res_positive = subprocess.run(
res = subprocess.run(
[
"grep",
"--recursive",
"--files-with-matches",
"--ignore-case",
"--word-regexp",
"--regexp",
"-rnw",
"-e",
r"file=",
str(target_dir),
],
text=True,
capture_output=True,
)
res_negative = subprocess.run(
[
"grep",
"--recursive",
"--files-with-matches",
"--ignore-case",
"--regexp",
r"node_modules",
str(target_dir),
],
text=True,
capture_output=True,
)
res = list(
set(res_positive.stdout.splitlines()).difference(
set(res_negative.stdout.splitlines())
)
)
except subprocess.CalledProcessError as e:
raise RuntimeError(
f"Command {e.cmd} returned with error (code {e.returncode}): {e.output}"
) from e
return res
return res.stdout.splitlines()


def main() -> None:
check_dependencies("grep")
project_root = pathlib.Path(__file__).parent.parent.parent
docs_dir = project_root / "docs"
assert docs_dir.exists()
docs_dir = pathlib.Path(__file__).parent.parent / "docs"
grep_output = run_grep(docs_dir)
excluded_documents = {
project_root / file_path
for file_path in ITEMS_IGNORED_FROM_LINE_NUMBER_SNIPPET_CHECKER
}
new_violations = set(grep_output).difference(excluded_documents)
if new_violations:
if grep_output:
print(
f"[ERROR] Found {len(new_violations)} snippets using file and line number syntax. Please use named snippet syntax:"
f"[ERROR] Found {len(grep_output)} snippets using file and line number syntax, please use named snippet syntax:"
)
for line in new_violations:
for line in grep_output:
print(line)
sys.exit(1)

Expand Down
127 changes: 0 additions & 127 deletions ci/checks/check_only_name_tag_snippets.py

This file was deleted.