Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generated_by attribute to File class #3344

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion mkdocs/structure/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import shutil
import warnings
from pathlib import PurePath
from typing import TYPE_CHECKING, Callable, Iterable, Iterator, Sequence
from typing import TYPE_CHECKING, Callable, Iterable, Iterator, Sequence, Optional
from urllib.parse import quote as urlquote

import jinja2.environment
Expand Down Expand Up @@ -193,6 +193,9 @@ class File:
inclusion: InclusionLevel = InclusionLevel.UNDEFINED
"""Whether the file will be excluded from the built site."""

generated_by: Optional[str] = None
"""Indicator for plugin developers to track which system created the File."""

@property
def src_path(self) -> str:
"""Same as `src_uri` (and synchronized with it) but will use backslashes on Windows. Discouraged."""
Expand Down Expand Up @@ -222,6 +225,7 @@ def __init__(
*,
dest_uri: str | None = None,
inclusion: InclusionLevel = InclusionLevel.UNDEFINED,
generated_by: Optional[str] = None,
) -> None:
self.page = None
self.src_path = path
Expand All @@ -233,6 +237,7 @@ def __init__(
self.abs_src_path = os.path.normpath(os.path.join(src_dir, self.src_uri))
self.abs_dest_path = os.path.normpath(os.path.join(dest_dir, self.dest_uri))
self.inclusion = inclusion
self.generated_by = generated_by

def __eq__(self, other) -> bool:
return (
Expand Down