我正在使用Sphinx记录Python项目。
该.. csv-table::指令似乎有点不一致。
主要问题是单元格中的新行。还有我可疑的心理健康。
如下代码:
.. csv-table::
:header: Header1, Header2, Header3
A, B, "These lines appear as one line,
even though they are written in two lines."
C, D, "| These lines appear as two lines,
| but they are indented, and my OCD will simply not allow it."
E, F, "| If I continue this line in another line,
it will appear in a new line."
G, H, "If there is a blank line between the two …Run Code Online (Sandbox Code Playgroud) 下面是一段抽象的代码,它简化了我遇到的问题。在此示例中,我有一个具有登录和注销属性的程序。登录与版本无关,注销与版本相关。
class A(class):
def __init__(self):
self.version = "1.0"
self.login = "logged in"
self.login_message = "hello logger"
self.logout = {"1.0": "logged out",
"2.0": "logged out 2.0"}
self.logout_message = {"1.0": "goodbye logger",
"2.0": "goodbye logger 2.0"}
def perform(self, executor):
executor.do(self.login)
executor.do(self.logout)
Run Code Online (Sandbox Code Playgroud)
executor是一个执行实际操作的外部接口,它应该接收一个字符串。该do功能无法更改。版本可以并且会在运行时改变,所以我正在寻找某种全局装饰器/属性,当访问装饰属性时,它会调用一个函数。目标是在每个版本发送到executor.do.
答案显然是改变perform功能executer.do(self.logout[self.version]),但self.login并self.logout不宜不同的方式访问。有些继承self.logout只是一个字符串,并且perform是共享的。
我在想这样的事情:
self.version = "1.0"
self.login = "logged in"
self.login_message = "hello logger"
@by_version
self.logout = {"1.0": "logged out",
"2.0": "logged out 2.0"} …Run Code Online (Sandbox Code Playgroud)