4747HELP_IGNORE_MESSAGES = """A regular expression to match linting issue messages against to ignore.
4848Can be set in config file.
4949"""
50+ HELP_SPHINX_SOURCE_DIR = """Path to the sphinx 'source' directory. Only necessary if sphinx is used
51+ and automatic discovery fails.
52+ May be relative or absolute.
53+ Can be set in config file.
54+ """
5055HELP_VERSION = "Print versions and exit."
5156
5257
@@ -87,6 +92,7 @@ def cli( # noqa: PLR0913, PLR0917
8792 ignore_substitutions : str | None = typer .Option (None , help = HELP_IGNORE_SUBSTITUTIONS ),
8893 ignore_languages : str | None = typer .Option (None , help = HELP_IGNORE_LANGUAGES ),
8994 ignore_messages : str | None = typer .Option (None , metavar = "REGEX" , help = HELP_IGNORE_MESSAGES ),
95+ sphinx_source_dir : pathlib .Path | None = typer .Option (None , help = HELP_SPHINX_SOURCE_DIR ),
9096 version : bool | None = typer .Option ( # noqa: ARG001, FBT001
9197 None , "--version" , callback = version_callback , is_eager = True , help = HELP_VERSION
9298 ),
@@ -99,6 +105,11 @@ def cli( # noqa: PLR0913, PLR0917
99105 typer .echo ("'-' is only allowed without additional files." , err = True )
100106 raise typer .Abort
101107
108+ sphinx_source_dir_absolute = sphinx_source_dir
109+ if sphinx_source_dir is not None and not sphinx_source_dir .is_absolute ():
110+ sphinx_source_dir_absolute = pathlib .Path .cwd () / sphinx_source_dir
111+ logger .info (f"Relative sphinx 'source' dir path resolved to: { sphinx_source_dir_absolute } " )
112+
102113 logger .info ("Create main configuration from CLI options." )
103114 rstcheck_config = config_mod .RstcheckConfig (
104115 config_path = config ,
@@ -110,6 +121,7 @@ def cli( # noqa: PLR0913, PLR0917
110121 ignore_substitutions = ignore_substitutions ,
111122 ignore_languages = ignore_languages ,
112123 ignore_messages = ignore_messages ,
124+ sphinx_source_dir = sphinx_source_dir_absolute ,
113125 )
114126
115127 exit_code = 1
0 commit comments