Skip to content

Commit caed765

Browse files
committed
docs: enhance documentation for File and Project classes with detailed descriptions and parameters
1 parent 2bfc3fd commit caed765

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

scubatrace/file.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121

2222
class File:
2323
"""
24-
Represents a file in a project.
24+
Represents a source code file in a project.
2525
"""
2626

27+
project: Project
28+
""" The project this file belongs to."""
29+
2730
def __init__(self, path: str, project: Project):
2831
"""
2932
Initializes a new instance of the class.
@@ -40,6 +43,17 @@ def __init__(self, path: str, project: Project):
4043

4144
@staticmethod
4245
def File(path: str, project: Project) -> File:
46+
"""
47+
Factory function to create a :class:`File` instance.
48+
49+
Args:
50+
path (str): The file relative path.
51+
project (Project): The project instance.
52+
53+
Returns:
54+
File: An instance of a language-specific File subclass corresponding to the project's language.
55+
"""
56+
4357
if project.language == lang.C:
4458
from .cpp.file import CFile
4559

@@ -90,10 +104,7 @@ def language(self) -> type[lang.Language]:
90104
@property
91105
def name(self) -> str:
92106
"""
93-
Returns the name of the file without the directory path.
94-
95-
Returns:
96-
str: The name of the file.
107+
The name of the file without the directory path.
97108
"""
98109
return os.path.basename(self._path)
99110

scubatrace/project.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class Project:
2424
Represents a codebase project with a specified path and language.
2525
"""
2626

27+
path: str
28+
"""The file system path to the project root."""
29+
language: type[lang.Language]
30+
"""The programming language type for the project."""
31+
2732
@staticmethod
2833
def Project(
2934
path: str,
@@ -32,13 +37,16 @@ def Project(
3237
) -> Project:
3338
"""
3439
Factory function to create a language-specific :class:`Project` instance.
40+
3541
Args:
3642
path (str): The file system path to the project root.
3743
language (type[Language]): The programming language type for the project.
3844
enable_lsp (bool, optional): Whether to enable Language Server Protocol (LSP) support. Defaults to True.
3945
Note: For PHP and Swift, LSP is always disabled.
46+
4047
Returns:
4148
Project: An instance of the appropriate language-specific Project subclass.
49+
4250
Raises:
4351
ValueError: If the provided language is not supported.
4452
"""

0 commit comments

Comments
 (0)