@@ -110,20 +110,16 @@ def build_with_flag_for_evidently(evidently_ref: str) -> list[str]:
110110 return [flag , evidently_ref ]
111111
112112
113- def format_revision_name (revision : str ) -> str :
114- """Format a git revision (branch, tag, or commit) into a clean directory name format."""
113+ def get_revision_info (revision : str ) -> tuple [str , str ]:
115114 # Check if it's a hash (hexadecimal string, typically 7-40 characters)
116- if re .match (r"^[0-9a-f]{7,40}$" , revision .lower ()):
117- prefix = "hash-"
118- # Check if it's a branch (contains "/" which is common in branch names)
119- elif "/" in revision :
120- prefix = "branch-"
121- else :
122- # Leave as is (could be a tag or simple branch name)
123- prefix = ""
115+ revision = revision .lower ()
116+ if re .match (r"^[0-9a-f]{7,40}$" , revision ):
117+ return (revision , f"hash: { revision } " )
118+ # Check if it's a semver version (e.g., v1.2.3, 1.2.3)
119+ elif re .match (r"^v?\d+\.\d+\.\d+$" , revision ):
120+ return (revision , revision )
124121
125- formatted = revision .replace ("/" , "-" ).lower ()
126- return f"{ prefix } { formatted } " if prefix else formatted
122+ return (revision .replace ("/" , "-" ), f"branch: { revision } " )
127123
128124
129125def format_local_path (path : Path ) -> str :
@@ -143,6 +139,7 @@ def generate_docs_by_git_revision(
143139 modules : list [str ] | None = None ,
144140 repo_url : str | None = None ,
145141 api_reference_index_href : str = "/" ,
142+ git_revision_name : str | None = None ,
146143) -> None :
147144 """Generate documentation from a git revision (branch, tag, or commit)."""
148145 github_repo_url = repo_url or GITHUB_REPO_URL
@@ -152,9 +149,11 @@ def generate_docs_by_git_revision(
152149 becho ("Generating documentation for git revision..." )
153150 yecho (revision )
154151
155- version = format_revision_name (revision ).replace ("-" , ": " , 1 )
156- github_blob_url = f"{ github_blob_prefix } /{ revision } /src/evidently/"
157- output_path = OUTPUT_DIR_PATH / format_revision_name (revision )
152+ revision_name = git_revision_name if git_revision_name else revision
153+
154+ path_to_artifact , version = get_revision_info (revision_name )
155+ github_blob_url = f"{ github_blob_prefix } /{ revision_name } /src/evidently/"
156+ output_path = OUTPUT_DIR_PATH / path_to_artifact
158157
159158 modules_to_use = merge_additional_modules_with_defaults (modules )
160159
@@ -301,6 +300,11 @@ def generate_docs(
301300 api_reference_index_href : str = Option (
302301 "/" , "--api-reference-index-href" , help = "Href path for the 'All versions' link (default: '/')"
303302 ),
303+ git_revision_name : str = Option (
304+ None ,
305+ "--git-revision-name" ,
306+ help = "Custom name for output directory when using --git-revision (default: auto-formatted revision name)" ,
307+ ),
304308):
305309 """Generate documentation for Evidently.
306310
@@ -341,6 +345,7 @@ def generate_docs(
341345 modules = modules_list ,
342346 repo_url = repo_url ,
343347 api_reference_index_href = api_reference_index_href ,
348+ git_revision_name = git_revision_name ,
344349 )
345350 elif local_source_code :
346351 generate_docs_from_local_source (
0 commit comments