Skip to content

Commit 83f778c

Browse files
author
awu42
committed
Edited validate script (pandas-dev#26941)
1 parent 927e3ed commit 83f778c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

scripts/validate_rst_title_capitalization.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import re
3131
import os
3232
from os import walk
33-
from typing import Generator, List, Tuple
33+
from typing import Generator, List
3434

3535

3636
class suppress_stdout_stderr:
@@ -163,7 +163,7 @@ def parseRST(rstFile: str) -> docutils.nodes.document:
163163
164164
'''
165165
# Create rst Parser object
166-
parser = docutils.parsers.rst.Parser()
166+
parser = Parser()
167167

168168
# Open and read the .rst file and store the string of data into input
169169
f = open(rstFile, "r")
@@ -233,9 +233,12 @@ def findBadTitlesInDoctree(document: docutils.nodes.document) -> Generator[
233233
# myText will be used to construct headings and append into titleList
234234
myText: str = ""
235235

236+
# lineno will be used to retrieve line numbers of certain headings
237+
lineno: int = 0
238+
236239
# A docutils.nodes object that stores a listOfMarkers text's grandparent node,
237240
# which should have a tagname of title
238-
markerGrandparent: docutils.nodes.Title
241+
markerGrandparent: docutils.nodes.Title = None
239242

240243
# True if the most recent node encountered had a parent with a listOfMarkers tagname
241244
# and a grandparent with a tagname of title
@@ -363,9 +366,9 @@ def main(source_paths: List[str], output_format: str) -> bool:
363366
# Print badTitleDictionary Results
364367
print()
365368
for key in badTitleDictionary:
366-
for titles in badTitleDictionary[key]:
367-
print(key + ":" + str(titles[1]) + ": " + errMessage
368-
+ " \"" + titles[0] + "\""
369+
for line in badTitleDictionary[key]:
370+
print(
371+
key + ":" + str(line[1]) + ": " + errMessage + " \"" + line[0] + "\""
369372
)
370373

371374
# Exit status of 1

0 commit comments

Comments
 (0)