File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ repos:
29
29
- id : no-space-in-cite
30
30
- id : tilde-cite
31
31
- id : unique-labels
32
+ # args:
33
+ # [
34
+ # # If present only check for uniqueness within each file.
35
+ # # Can be useful if a repository contains multiple main files.
36
+ # "--individual",
37
+ # ]
32
38
- id : cleveref-instead-of-autoref
33
39
- repo : https://github.com/pre-commit/pre-commit-hooks
34
40
rev : v3.3.0
Original file line number Diff line number Diff line change @@ -80,6 +80,11 @@ def search(files: t.List[t.IO[str]]) -> bool:
80
80
81
81
def main () -> None :
82
82
parser = argparse .ArgumentParser ()
83
+ parser .add_argument (
84
+ "--individual" ,
85
+ action = "store_true" ,
86
+ help = "Allow duplicate labels if they are in different files" ,
87
+ )
83
88
parser .add_argument (
84
89
"files" ,
85
90
metavar = "FILE" ,
@@ -90,7 +95,10 @@ def main() -> None:
90
95
args = parser .parse_args ()
91
96
92
97
files = sorted (args .files , key = lambda f : f .name )
93
- found_multiple_definitions = search (files )
98
+ if args .individual :
99
+ found_multiple_definitions = any (search ([f ]) for f in files )
100
+ else :
101
+ found_multiple_definitions = search (files )
94
102
if found_multiple_definitions :
95
103
sys .exit ("Found multiple definitions of the same label" )
96
104
You can’t perform that action at this time.
0 commit comments