@@ -101,8 +101,8 @@ def _docs_list_links(doc_config: Path):
101101 doc_config ,
102102 tmpdir ,
103103 ],
104- capture_output = True ,
105- text = True
104+ capture_output = True ,
105+ text = True ,
106106 )
107107 if sp .returncode >= 2 :
108108 return sp .returncode , sp .stderr
@@ -116,17 +116,9 @@ def _docs_list_links(doc_config: Path):
116116 file_links .append (line )
117117 file_links .sort (key = lambda file : file ["filename" ])
118118 return 0 , "\n " .join (
119- f"filename: { fl ['filename' ]} :{ fl ['lineno' ]} -> uri: { fl ['uri' ]} " for fl in file_links
120- )
121-
122-
123- @nox .session (name = "docs:links" , python = False )
124- def docs_list_links (session : Session ) -> None :
125- """List all the links within the documentation."""
126- r_code , text = _docs_list_links (PROJECT_CONFIG .doc )
127- print (text )
128- if r_code != 0 :
129- session .error ()
119+ f"filename: { fl ['filename' ]} :{ fl ['lineno' ]} -> uri: { fl ['uri' ]} "
120+ for fl in file_links
121+ )
130122
131123
132124def _docs_links_check (doc_config : Path , args ):
@@ -146,7 +138,18 @@ def _docs_links_check(doc_config: Path, args):
146138 dst = Path (args .output ) / "link-check-output.json"
147139 shutil .copyfile (result_json , dst )
148140 print (f"file generated at path: { result_json .resolve ()} " )
149- return sp .returncode , None if sp .returncode >= 2 else (tmpdir / "output.txt" ).read_text ()
141+ return sp .returncode , (
142+ None if sp .returncode >= 2 else (tmpdir / "output.txt" ).read_text ()
143+ )
144+
145+
146+ @nox .session (name = "docs:links" , python = False )
147+ def docs_list_links (session : Session ) -> None :
148+ """List all the links within the documentation."""
149+ r_code , text = _docs_list_links (PROJECT_CONFIG .doc )
150+ print (text )
151+ if r_code != 0 :
152+ session .error ()
150153
151154
152155@nox .session (name = "docs:links:check" , python = False )
@@ -158,15 +161,15 @@ def docs_links_check(session: Session) -> None:
158161 formatter_class = argparse .ArgumentDefaultsHelpFormatter ,
159162 )
160163 parser .add_argument (
161- "-o" , "--output" , type = Path , help = "path to output file " , default = None
164+ "-o" , "--output" , type = Path , help = "path to copy the output json " , default = None
162165 )
163166 args = parser .parse_args (session .posargs )
164167 r_code , problems = _docs_links_check (PROJECT_CONFIG .doc , args )
165168 if r_code >= 2 :
166169 session .error (2 )
167170 if r_code == 1 or problems != "" :
168- escape_rot = "\033 [31m"
169- print (escape_rot + "errors:" )
171+ escape_red = "\033 [31m"
172+ print (escape_red + "errors:" )
170173 print (problems )
171174 session .error (1 )
172175
0 commit comments