4646
4747
4848class PdfRestFileID (str ):
49- """A str-like type representing:
49+ """Str-like identifier for pdfRest files.
50+
51+ Format:
5052 [optional '1' or '2' prefix] + [UUIDv4 with hyphens]
5153
5254 Examples:
@@ -71,6 +73,17 @@ class PdfRestFileID(str):
7173 )
7274
7375 def __new__ (cls , value : str ) -> PdfRestFileID :
76+ """Create a normalized file identifier from a validated string.
77+
78+ Args:
79+ value: Candidate pdfRest file id string.
80+
81+ Returns:
82+ Lower-cased, validated file id value.
83+
84+ Raises:
85+ ValueError: If `value` is not a valid prefixed UUIDv4 identifier.
86+ """
7487 if not cls ._PY_PATTERN .fullmatch (value ):
7588 msg = (
7689 "Invalid PdfRestPrefixedUUID4. Expected: "
@@ -116,8 +129,14 @@ def is_valid(cls, value: str) -> bool:
116129 def from_parts (
117130 cls , u : str | _uuid .UUID , prefix : int | str | None = None
118131 ) -> PdfRestFileID :
119- """Build from a UUIDv4 (str or uuid.UUID) and an optional prefix (1 or 2).
120- Raises ValueError if not a v4 UUID or bad prefix.
132+ """Build a file id from a UUIDv4 and optional prefix.
133+
134+ Args:
135+ u: UUID value as string or `uuid.UUID`.
136+ prefix: Optional leading prefix (`1` or `2`).
137+
138+ Raises:
139+ ValueError: If the UUID is not version 4 or the prefix is invalid.
121140 """
122141 if isinstance (prefix , int ):
123142 prefix = str (prefix ) # allow 1/2 as int
@@ -156,9 +175,11 @@ def generate(cls, prefix: int | str | None = None) -> PdfRestFileID:
156175 # -------------------------
157176 @classmethod
158177 def __get_pydantic_core_schema__ (cls , source_type : Any , handler : Any ) -> CoreSchema :
159- """Build a Pydantic v2 core schema that accepts:
160- - a UUID (validated as v4) -> converted to this type (no prefix)
161- - a string matching our pattern
178+ """Build a Pydantic v2 core schema for `PdfRestFileID`.
179+
180+ Accepted inputs:
181+ - a UUID (validated as v4) converted to this type with no prefix
182+ - a string matching the `PdfRestFileID` pattern
162183 """
163184 from pydantic_core import core_schema
164185
@@ -272,8 +293,10 @@ class PdfRestFile(BaseModel):
272293
273294
274295class PdfRestFileBasedResponse (BaseModel ):
275- """Represents a response from a pdfRest API operation that is file-based, allowing
276- handling of input and output files along with additional warnings.
296+ """Response model for file-based pdfRest operations.
297+
298+ Includes input file identifiers, output files, and optional warnings from
299+ the API response payload.
277300 """
278301
279302 # Allow all extra fields to be stored and serialized
@@ -678,35 +701,43 @@ class ExtractedTextFullTextPages(BaseModel):
678701
679702
680703class ExtractedTextFullText (RootModel [str | ExtractedTextFullTextPages ]):
681- """Represents full-text extraction in either "document" (str) or "page" (object)
682- modes while providing convenience accessors for both forms.
704+ """Full-text extraction payload in document or per-page mode.
705+
706+ Wraps either a single document-level string or a per-page text object and
707+ provides convenience accessors for both shapes.
683708 """
684709
685710 root : str | ExtractedTextFullTextPages
686711 """Raw payload in document-text or per-page form."""
687712
688713 @property
689714 def document_text (self ) -> str | None :
690- """Return the document-level string. Falls back to space-joining per-page text
691- when only the page-structured payload is available.
715+ """Return document-level text for either payload shape.
716+
717+ Falls back to joining per-page text when only the page-structured
718+ payload is available.
692719 """
693720 if isinstance (self .root , str ):
694721 return self .root
695722 return " " .join (page .text for page in self .root .pages )
696723
697724 @property
698725 def pages (self ) -> list [ExtractedTextFullTextPage ]:
699- """Return page entries when pdfRest emits per-page text.
700- Raises ValueError when the payload is in document-string mode.
726+ """Return per-page text entries when page mode is available.
727+
728+ Raises:
729+ ValueError: If the payload is in document-string mode.
701730 """
702731 if isinstance (self .root , ExtractedTextFullTextPages ):
703732 return self .root .pages
704733 msg = "full text payload was emitted in document mode; page data unavailable"
705734 raise ValueError (msg )
706735
707736 def iter_pages (self ) -> list [ExtractedTextFullTextPage ]:
708- """Convenience helper that provides a stable iterable without requiring
709- callers to guard against the document-only representation.
737+ """Return per-page text entries or an empty list in document mode.
738+
739+ This helper avoids forcing callers to catch mode errors when they only
740+ need an iterable.
710741 """
711742 try :
712743 return self .pages
0 commit comments