Skip to content

Commit c14573d

Browse files
committed
Document File
1 parent bd6af67 commit c14573d

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

mystbin/paste.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,26 @@
3838

3939

4040
class File:
41+
"""Represents a single file within a mystb.in paste.
42+
43+
Attributes
44+
-----------
45+
filename: :class:`str`
46+
The file's name.
47+
content: :class:`str`
48+
The file's contents.
49+
syntax: Optional[:class:`str`]
50+
The file's syntax, if given.
51+
lines_of_code: Optional[:class:`int`]
52+
The lines of code within the file.
53+
character_count: Optional[:class:`int`]
54+
The character count of the file.
55+
56+
57+
.. note::
58+
The ``lines_of_code`` and ``character_count`` come from the API and should not be provided by the user.
59+
"""
60+
4161
__slots__ = (
4262
"filename",
4363
"content",
@@ -58,7 +78,7 @@ def __init__(
5878
self.filename: str = filename
5979
self.content: str = content
6080
self.syntax: Optional[str] = syntax
61-
self.lines_of_code: int = lines_of_code or len(content.split("\n"))
81+
self.lines_of_code: int = lines_of_code or content.count("\n")
6282
self.character_count: int = character_count or len(content)
6383

6484
@classmethod

0 commit comments

Comments
 (0)