Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
public-apis
Commits
a935a05d
Unverified
Commit
a935a05d
authored
Jan 16, 2022
by
Matheus Felipe
Browse files
Change section -> category
parent
de1b6f59
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/validate/format.py
View file @
a935a05d
...
...
@@ -22,7 +22,7 @@ num_segments = 5
errors
=
[]
title_links
=
[]
anchor_re
=
re
.
compile
(
anchor
+
'\s(.+)'
)
section_title
_re
=
re
.
compile
(
'\*\s\[(.*)\]'
)
category_title_in_index
_re
=
re
.
compile
(
'\*\s\[(.*)\]'
)
link_re
=
re
.
compile
(
'\[(.+)\]\((http.*)\)'
)
# Type aliases
...
...
@@ -195,23 +195,23 @@ def check_file_format(filename: str) -> None:
for
line_num
,
line
in
enumerate
(
lines
):
section
_title_match
=
section_title
_re
.
match
(
line
)
if
section
_title_match
:
title_links
.
append
(
section
_title_match
.
group
(
1
))
category
_title_match
=
category_title_in_index
_re
.
match
(
line
)
if
category
_title_match
:
title_links
.
append
(
category
_title_match
.
group
(
1
))
# check each
section
for the minimum number of entries
# check each
category
for the minimum number of entries
if
line
.
startswith
(
anchor
):
category_match
=
anchor_re
.
match
(
line
)
if
category_match
:
if
category_match
.
group
(
1
)
not
in
title_links
:
message
=
error_message
(
line_num
,
f
'
section
header (
{
category_match
.
group
(
1
)
}
) not added
as a title link
'
)
message
=
error_message
(
line_num
,
f
'
category
header (
{
category_match
.
group
(
1
)
}
) not added
to Index section
'
)
errors
.
append
(
message
)
else
:
message
=
error_message
(
line_num
,
'
section
header is not formatted correctly'
)
message
=
error_message
(
line_num
,
'
category
header is not formatted correctly'
)
errors
.
append
(
message
)
if
num_in_category
<
min_entries_per_section
:
message
=
error_message
(
category_line
,
f
'
{
category
}
section
does not have the minimum
{
min_entries_per_section
}
entries (only has
{
num_in_category
}
)'
)
message
=
error_message
(
category_line
,
f
'
{
category
}
category
does not have the minimum
{
min_entries_per_section
}
entries (only has
{
num_in_category
}
)'
)
errors
.
append
(
message
)
category
=
line
.
split
(
' '
)[
1
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment