py2403homework.utils#

提供了一些有用的类型,用于生成作业文档源文件。

This module provides some useful types to generate source files of homework documentation.

Classes

Event([description, name, date, content])

普通事件类型,也是所有 event type 的基类。

Generatable()

可生成文档类型的抽象基类。

Homework([date, date_limit, description, ...])

Library()

Simple(title[, content])

可生成文档类型的一个简单实现。

Subject(name[, content])

class py2403homework.utils.Generatable[源代码]#

基类:object

可生成文档类型的抽象基类。

Abstract base class of doc-generatable types.

abstractmethod dumps() str[源代码]#

实现生成 reStructuredText 形式的文档的功能。

Implement generating reStructuredText format of a documentation.

返回:

reStructuredText 源码 sourcecode

返回类型:

str

class py2403homework.utils.Simple(title: str, content: str | None = None)[源代码]#

基类:Generatable

可生成文档类型的一个简单实现。

A simple implementation of a doc-generatable type.

参数:
  • title -- 章节标题,不能超过一行 section title within a line

  • content -- 标题后的正文 the body after title

TITLE_SYMBOL: str = '~'#

装饰标题所使用的标点符号

punctuation character for marking titles

title#

title 参数设置

set by argument title

content#

content 参数设置

set by argument content

__str__()[源代码]#

dumps() 方法的快捷方式。

The shortcut for dumps().

返回类型:

str

dumps() str[源代码]#

生成文档。

Generate the documentation.

先调用 generate_title() 生成标题部分,与后面的 content\n\n 相隔,即一个空行。

Call generate_title() first to generate the title part, followed by \n\n (A blank line), then content.

generate_title() str[源代码]#

生成文档标题部分的 reStructuredText 形式。

Generate reStructuredText format of the title part of the documentation.

标题最先出现,再是一些用于装饰的标点符号。

The title comes first, then punctuation characters for marking.

返回:

reStructuredText 格式的章节标记

class py2403homework.utils.Event(description: str | None = None, name: str | None = None, date: date | str | None = None, content: str | None = None)[源代码]#

基类:Simple

普通事件类型,也是所有 event type 的基类。

General event type, also the base class of all event types.

参数:
  • description -- 对于事件的描述,若不为空,则标题后会加上 `` --- {description}``

  • name -- 事件名称,默认使用 DEFAULT_NAME

  • date -- 事件日期,若为空则调用 time.strftime();若为字符串则直接使用,为 datetime.date 类型时用 '{date.year:0>4}/{date.month:0>2}/{date.day:0>2}' 的格式转换,并放在标题的开头

DEFAULT_NAME: str = '事件'#

默认事件类型名称,作为 name 参数的默认值使用

default event format name, used as the default value of argument name

DEFAULT_CONTENT: str = ''#

默认内容,作为 content 参数的默认值使用

default content, used as the default value of argument content

class py2403homework.utils.Homework(date: date | str | None = None, date_limit: str | None = None, description: str | None = None, content: str | None = None, content_fmt: str | None = None)[源代码]#

基类:Event

DEFAULT_NAME: str = '作业'#

默认事件类型名称,作为 name 参数的默认值使用

default event format name, used as the default value of argument name

dumps()[源代码]#

生成文档。

Generate the documentation.

先调用 generate_title() 生成标题部分,与后面的 content\n\n 相隔,即一个空行。

Call generate_title() first to generate the title part, followed by \n\n (A blank line), then content.