-
-
Notifications
You must be signed in to change notification settings - Fork 19k
CI: Adding script to validate consistent and correct capitalization among headings in documentation (#26941) #31114
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
Changes from 55 commits
85e3fe6
e2d5354
f089c0c
2dd5791
2294331
c06c951
2ffeee0
1364f86
bb535ae
6b51df6
d6198a6
21693b6
0810c09
30c4f8c
aabd136
4c83edb
50661c3
f513f29
2d3cfe7
4ceea5e
11556b7
e55776f
9fc312a
635163d
c4ff8bd
927e3ed
83f778c
1907d45
de06ec8
b7c0bfd
3d3a7f4
7ea58df
d71be41
60d8db9
0e344ad
3757712
3d95777
56bfc44
0ec38e2
deddc2d
0311fe0
3256615
df01730
c1e3abb
9a9a57a
bafbf96
dd5c983
5f0f84a
2fc019f
ee45f98
88dfc46
78a49c1
95d3488
1c7de87
f4ffd32
3d2e9ce
687053f
ed3cdc6
c690281
c9775cc
66c651a
ac5c5b7
ceedac5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,211 @@ | ||||||
#!/usr/bin/env python | ||||||
""" | ||||||
Validate that the titles in the rst files follow the proper capitalization convention. | ||||||
|
||||||
Print the titles that do not follow the convention. | ||||||
|
||||||
Usage:: | ||||||
./scripts/validate_rst_title_capitalization.py doc/source/development/contributing.rst | ||||||
./scripts/validate_rst_title_capitalization.py doc/source/ | ||||||
|
||||||
""" | ||||||
import argparse | ||||||
import sys | ||||||
import re | ||||||
import os | ||||||
from typing import Tuple, Generator, List | ||||||
import glob | ||||||
|
||||||
|
||||||
CAPITALIZATION_EXCEPTIONS = { | ||||||
"pandas", | ||||||
"Python", | ||||||
"IPython", | ||||||
"PyTables", | ||||||
"Excel", | ||||||
"JSON", | ||||||
"HTML", | ||||||
"SAS", | ||||||
"SQL", | ||||||
"BigQuery", | ||||||
"STATA", | ||||||
"Interval", | ||||||
"PEP8", | ||||||
"Period", | ||||||
"Series", | ||||||
"Index", | ||||||
"DataFrame", | ||||||
"C", | ||||||
"Git", | ||||||
"GitHub", | ||||||
"NumPy", | ||||||
"Apache", | ||||||
"Arrow", | ||||||
"Parquet", | ||||||
"MultiIndex", | ||||||
"NumFOCUS", | ||||||
"sklearn", | ||||||
"Docker", | ||||||
} | ||||||
|
||||||
CAP_EXCEPTIONS_DICT = {word.lower(): word for word in CAPITALIZATION_EXCEPTIONS} | ||||||
|
||||||
err_msg = "Heading capitalization formatted incorrectly. Please correctly capitalize" | ||||||
|
||||||
|
||||||
def correct_title_capitalization(title: str) -> str: | ||||||
""" | ||||||
Algorithm to create the correct capitalization for a given title. | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
title : str | ||||||
Heading string to correct. | ||||||
|
||||||
Returns | ||||||
------- | ||||||
correct_title : str | ||||||
|
correct_title : str | |
str |
tonywu1999 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
tonywu1999 marked this conversation as resolved.
Show resolved
Hide resolved
tonywu1999 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
tonywu1999 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No blank line here
tonywu1999 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
tonywu1999 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
tonywu1999 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
tonywu1999 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
tonywu1999 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better remove this blank line (we're not validating this docstring, but this blank line would make it fail if we do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're using this just once, I'd move it to the function where it's being used.