Skip to content

Commit

Permalink
📝 Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kinegratii committed Jan 30, 2024
1 parent 39a9a1c commit b7ec13d
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Borax 的 python 版本要求如下
| borax 版本 | python版本 | 维护状态 |
| ------ | ------ | ------ |
| 4.1.x | 3.9+ | 维护开发 |
| 4.0.0 | 3.7+ | 不再维护 |
| 4.0.0 | 3.7+ | 维护至2024年12月31日 |
| 3.x | 3.5+ | 不再维护 |

可以通过 *pip* 安装 :
Expand All @@ -59,15 +59,15 @@ borax~=4.1

一个支持1900-2100年的农历日期工具库。

> 本模块的数据和算法参考自项目 [jjonline/calendar.js](https://github.com/jjonline/calendar.js)
> 本模块的数据和算法参考自项目 [jjonline/calendar.js](https://github.com/jjonline/calendar.js) ,部分算法和数据有所修改
创建日期,日期推算

```python
from datetime import timedelta
from borax.calendars import LunarDate

# 获取今天的农历日期(农历2018年七月初一
# 获取今天的农历日期(农历二〇一八年七月初一
print(LunarDate.today()) # LunarDate(2018, 7, 1, 0)

# 将公历日期转化为农历日期
Expand Down Expand Up @@ -100,7 +100,7 @@ festival = LunarFestival(month=1, day=1)
print(festival.description) # '农历每年正月初一'

# 下一次春节的具体日期以及距离天数
print(festival.countdown()) # (273, <GeneralDate:2022-02-01(二〇二二年正月初一)>)
print(festival.countdown()) # (273, <WrappedDate:2022-02-01(二〇二二年正月初一)>)

# 接下来5个春节的日期 ['2022-02-01(二〇二二年正月初一)', '2023-01-22(二〇二三年正月初一)', '2024-02-10(二〇二四年正月初一)', '2025-01-29(二〇二五年正月初一)', '2026-02-17(二〇二六年正月初一)']
print([str(wd) for wd in festival.list_days(start_date=date.today(), count=5)])
Expand Down
6 changes: 4 additions & 2 deletions borax/calendars/festivals2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from datetime import date, timedelta, datetime
from functools import cached_property
from pathlib import Path
from typing import List, Tuple, Optional, Union, Iterator, Set, Generator, Sequence
from typing import List, Tuple, Optional, Union, Iterator, Set, Generator, Sequence, Literal

from borax.calendars.dataset import get_festival_dataset_path
from borax.calendars.lunardate import LunarDate, LCalendars, TermUtils, TextUtils, TERMS_CN
Expand Down Expand Up @@ -1219,13 +1219,15 @@ def load_term_festivals(self):
return self.extend_term_festivals()

@classmethod
def load_builtin(cls, identifier: str = 'basic') -> 'FestivalLibrary':
def load_builtin(cls, identifier: Literal['basic', 'empty', 'ext1', 'zh-Hans'] = 'basic') -> 'FestivalLibrary':
"""Load builtin library in borax project.
Available Identifiers: basic, zh-Hans, ext1, empty
"""
if identifier == 'empty':
return FestivalLibrary()
if identifier == 'zh-Hans':
warnings.warn('identifier "zh-Hans" is deprecated.Use "basic" instead. ', DeprecationWarning)

Check warning on line 1230 in borax/calendars/festivals2.py

View check run for this annotation

Codecov / codecov/patch

borax/calendars/festivals2.py#L1230

Added line #L1230 was not covered by tests
return cls.load_file(get_festival_dataset_path(identifier))

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Borax 的 python 版本要求如下
| borax 版本 | python版本 | 维护状态 |
| ------ | ------ | ------ |
| 4.1.x | 3.9+ | 维护开发 |
| 4.0.0 | 3.7+ | 不再维护 |
| 4.0.0 | 3.7+ | 维护至2024年12月31日 |
| 3.x | 3.5+ | 不再维护 |

可以通过 *pip* 安装 :
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 更新日志

## v4.1.0 (20240330)
## v4.1.0 (20240131)

> Borax最低python版本要求为python3.9
Expand Down
53 changes: 53 additions & 0 deletions docs/develop_note.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 开发笔记

## python版本约束

Borax 4.1.0开始,要求python最低版本为3.9,主要是引入了新的特性,包括:

- `functools.cached_property` 装饰器 (python3.8+)
- `typing.Literal` 类型注释(python3.8+)

## 代码风格

项目代码风格以 [PEP8](https://peps.python.org/pep-0008/) + pycharm 的配置为基准,并增加下列的一些自定义规则。

- 代码每行长度限制为120
- 函数复杂度限制为25
- 禁止使用 `\` 作为代码行分割的标志,需使用括号
- 不再接受注释方式的类型声明,如 `a = 2 # type:int` 应该为 `a:int = 2` (pyflake触发 `F401` 警告)

## 项目开发

Borax 默认使用 *pyproject.toml* 文件作为项目配置文件,具体包括单元测试、静态检查等内容。

*pyproject.toml* 配置文件目前包括以下内容:

| 功能 | 开发库 | 独立配置文件 | pyproject.toml配置段 | 备注 |
| ------------ | -------- | ------------ | -------------------- | -------------------------- |
| 项目基本信息 | - | | [project] | |
| 单元测试 | nose2 | | | |
| 覆盖率 | coverage | | [tool.coverage] | |
| 静态检查 | flake8 | | [tool.flake8] | 通过 Flake8-pyproject 实现 |
| 静态检查 | pylint | .pylintrc | | 配置项过多,不进行迁移 |
| 项目构建 | build | | [tool.setuptool] | |



## 项目构建

项目使用 `build` 作为包构建工具,使用下列命令生成 wheel 文件。

```shell
python -m build -w
```

## 文档编写

除了常规的模块文档外,项目包括以下两种日志文档:

- 更新日志:每个版本的changelog。
- 发布日志:某些重要版本的 release note,每个版本单独一篇文章。

## 文档生成

Borax项目使用 [Material for MkDocs ](https://squidfunk.github.io/mkdocs-material/) 作为文档生成工具,不再支持 docsify 文档生成工具。
2 changes: 1 addition & 1 deletion docs/release-note/v410.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# v4.1.0发布日志

> 发布时间:2024年3月30日
> 发布时间:2024年1月31日


Expand Down

0 comments on commit b7ec13d

Please sign in to comment.