Skip to content

Commit

Permalink
docs: 新增 doc_gen 基于 stubgen 自动生成模块 markdown 文档,同时补充、勘误部分代码中的文档错误,以及 _…
Browse files Browse the repository at this point in the history
…sidebar

[提议] 将文档编写的重心由 module  转向 example  #293
  • Loading branch information
Nemo2011 committed Aug 26, 2024
1 parent 0eafcac commit f924fec
Show file tree
Hide file tree
Showing 71 changed files with 8,769 additions and 5,179 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ virtualenv/
.idea/
.vscode/settings.json
.vscode/launch.json
# Doc Generater
.doc_cache/
6 changes: 6 additions & 0 deletions bilibili_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
DynamicExceedImagesException,
CredentialNoSessdataException,
CredentialNoDedeUserIDException,
ExClimbWuzhiException,
StatementException,
CredentialNoAcTimeValueException,
)
from . import (
app,
Expand Down Expand Up @@ -167,4 +170,7 @@
"video_zone",
"vote",
"watchroom",
"ExClimbWuzhiException",
"StatementException",
"CredentialNoAcTimeValueException",
]
12 changes: 12 additions & 0 deletions bilibili_api/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ def __init__(self, rlid: int, credential: Union[Credential, None] = None):
self.credential: Credential = credential

def get_rlid(self) -> int:
"""
获取 rlid
Returns:
int: rlid
"""
return self.__rlid

async def get_content(self) -> dict:
Expand Down Expand Up @@ -186,6 +192,12 @@ def __init__(self, cvid: int, credential: Union[Credential, None] = None):
self.__dyn_id = cache_pool.article_dyn_id[self.__cvid]

def get_cvid(self) -> int:
"""
获取 cvid
Returns:
int: cvid
"""
return self.__cvid

def get_type(self) -> ArticleType:
Expand Down
12 changes: 12 additions & 0 deletions bilibili_api/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def __init__(self, auid: int, credential: Union[Credential, None] = None):
self.__auid = auid

def get_auid(self) -> int:
"""
获取 auid
Returns:
int: auid
"""
return self.__auid

async def get_info(self) -> dict:
Expand Down Expand Up @@ -114,6 +120,12 @@ def __init__(self, amid: int, credential: Union[Credential, None] = None):
self.credential: Credential = credential if credential is not None else Credential()

def get_amid(self) -> int:
"""
获取 amid
Returns:
int: amid
"""
return self.__amid

async def get_info(self) -> dict:
Expand Down
16 changes: 16 additions & 0 deletions bilibili_api/audio_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@


class SongCategories:
"""
歌曲分类
"""
class ContentType(Enum): # cr_type
"""
内容类型
Expand Down Expand Up @@ -177,6 +180,9 @@ class AudioType(Enum):


class CompilationCategories:
"""
专辑分类
"""
class SongType(Enum):
"""
声音类型
Expand Down Expand Up @@ -802,6 +808,16 @@ async def get_upinfo(param: Union[int, str], credential: Credential) -> List[dic


async def upload_cover(cover: Picture, credential: Credential) -> str:
"""
上传封面
Args:
cover (Picture): 封面
credential (Credential): 凭据类
Returns:
str: 封面链接
"""
api = _API["image"]
# 小于 3MB
raise_for_statement(os.path.getsize(cover) < 1024 * 1024 * 3, "3MB size limit")
Expand Down
54 changes: 51 additions & 3 deletions bilibili_api/bangumi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from . import settings
from .video import Video
from .utils.utils import get_api
from .utils.utils import get_api, raise_for_statement
from .utils.credential import Credential
from .exceptions.ApiException import ApiException
from .utils.network import Api, get_session, HEADERS
Expand Down Expand Up @@ -742,6 +742,9 @@ class IndexFilterMeta:
"""

class Anime:
"""
动画
"""
def __init__(
self,
version: IndexFilter.Version = IndexFilter.Version.ALL,
Expand Down Expand Up @@ -787,6 +790,9 @@ def __init__(
self.style_id = style

class Movie:
"""
电影
"""
def __init__(
self,
area: IndexFilter.Area = IndexFilter.Area.ALL,
Expand Down Expand Up @@ -814,6 +820,9 @@ def __init__(
self.season_status = payment

class Documentary:
"""
纪录片
"""
def __init__(
self,
release_date: str = -1,
Expand All @@ -839,6 +848,9 @@ def __init__(
self.producer_id = producer

class TV:
"""
TV
"""
def __init__(
self,
area: IndexFilter.Area = IndexFilter.Area.ALL,
Expand All @@ -864,6 +876,9 @@ def __init__(
self.season_status = payment

class GuoChuang:
"""
国创
"""
def __init__(
self,
version: IndexFilter.Version = IndexFilter.Version.ALL,
Expand Down Expand Up @@ -897,6 +912,9 @@ def __init__(
self.style_id = style

class Variety:
"""
综艺
"""
def __init__(
self,
style: IndexFilter.Style.Variety = IndexFilter.Style.Variety.ALL,
Expand Down Expand Up @@ -1048,9 +1066,21 @@ def __init__(
]

def get_media_id(self) -> int:
"""
获取 media_id
Returns:
int: 获取 media_id
"""
return self.__media_id

def get_season_id(self) -> int:
"""
获取季度 id
Returns:
int: 获取季度 id
"""
return self.__ssid

def get_up_info(self) -> dict:
Expand All @@ -1072,9 +1102,21 @@ def get_raw(self) -> Tuple[dict, bool]:
return self.__raw, self.oversea

def set_media_id(self, media_id: int) -> None:
"""
设置 media_id
Args:
media_id (int): 设置 media_id
"""
self.__init__(media_id=media_id, credential=self.credential)

def set_ssid(self, ssid: int) -> None:
"""
设置季度 id
Args:
ssid (int): 设置季度 id
"""
self.__init__(ssid=ssid, credential=self.credential)

async def get_meta(self) -> dict:
Expand Down Expand Up @@ -1339,10 +1381,10 @@ def get_epid(self) -> int:
return self.__epid

def set_aid_e(self, aid: int) -> None:
print("Set aid is not allowed in Episode")
raise_for_statement(0, "Set aid is not allowed in Episode")

def set_bvid_e(self, bvid: str) -> None:
print("Set bvid is not allowed in Episode")
raise_for_statement(0, "Set bvid is not allowed in Episode")

async def get_cid(self) -> int:
"""
Expand All @@ -1363,6 +1405,12 @@ def get_bangumi(self) -> "Bangumi":
return self.bangumi # type: ignore

def set_epid(self, epid: int) -> None:
"""
设置 epid
Args:
epid (int): epid
"""
self.__init__(epid, self.credential)

async def get_episode_info(self) -> dict:
Expand Down
17 changes: 16 additions & 1 deletion bilibili_api/black_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,28 @@ async def get_reason(self) -> BlackReasonType:
return BlackReasonType((await self.get_details())["reasonType"])

async def get_id(self) -> int:
"""
获取小黑屋 id
Returns:
int: 小黑屋 id
"""
return self.__id

async def set_id(self, id_) -> None:
async def set_id(self, id_: int) -> None:
"""
设置小黑屋 id
Args:
id_ (int): 小黑屋 id
"""
self.__init__(id_, self.credential)


class JuryCase:
"""
案件仲裁
"""
def __init__(self, case_id: str, credential: Credential):
"""
Args:
Expand Down
42 changes: 42 additions & 0 deletions bilibili_api/cheese.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,30 @@ def __init__(
self.__season_id = int(meta["season_id"])

def set_season_id(self, season_id: int) -> None:
"""
设置季度 id
Args:
season_id (int): 季度 id
"""
self.__init__(season_id=season_id)

def set_ep_id(self, ep_id: int) -> None:
"""
设置 epid 并通过 epid 找到课程
Args:
ep_id (int): epid
"""
self.__init__(ep_id=ep_id)

def get_season_id(self) -> int:
"""
获取季度 id
Returns:
int: 季度 id
"""
return self.__season_id

async def get_meta(self) -> dict:
Expand Down Expand Up @@ -166,9 +184,21 @@ def __init__(self, epid, credential: Union[Credential, None] = None):
self.__cid = meta["cid"]

def get_aid(self) -> int:
"""
获取 aid
Returns:
int: aid
"""
return self.__aid

def get_cid(self) -> int:
"""
获取 cid
Returns:
int: cid
"""
return self.__cid

def get_meta(self) -> dict:
Expand All @@ -190,9 +220,21 @@ def get_cheese(self) -> "CheeseList":
return self.cheese

def set_epid(self, epid: int) -> None:
"""
设置 epid
Args:
epid (int): epid
"""
self.__init__(epid, self.credential)

def get_epid(self) -> int:
"""
获取 epid
Returns:
int: epid
"""
return self.__epid

async def get_download_url(self) -> dict:
Expand Down
18 changes: 18 additions & 0 deletions bilibili_api/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,30 @@ def __get_data(self, status: bool) -> dict:
}

def get_rpid(self) -> int:
"""
获取评论 rpid
Returns:
int: rpid
"""
return self.__rpid

def get_type(self) -> CommentResourceType:
"""
获取评论资源类型
Returns:
CommentResourceType: 资源类型
"""
return self.__type

def get_oid(self) -> int:
"""
获取评论对应 oid
Returns:
int: oid
"""
return self.__oid

async def like(self, status: bool = True) -> dict:
Expand Down
Loading

0 comments on commit f924fec

Please sign in to comment.