小编wil*_*att的帖子

如何在__init__中使用sphinx自动模块和公开函数

我有一个看起来像的文件夹结构:

project/
    mymodule/
        __init__.py
        m1.py
        m2.py
        sub1/
            __init__.py
            s1.py
            s2.py
Run Code Online (Sandbox Code Playgroud)

mymod/__init__.py

"""The __init__ docstr"""
from m1 import *
from m2 import *
Run Code Online (Sandbox Code Playgroud)

mymod/m1.py

"""m1 doc str"""
def func1():
    """func1 docstr"""
    return 1
Run Code Online (Sandbox Code Playgroud)

mymod/m2.py

"""m2 doc str"""
def func2():
    """func2 docstr"""
    return 2
Run Code Online (Sandbox Code Playgroud)

mymod/sub1/__init__.py

"""The sub1 __init__ docstr"""
from s1 import *
from s2 import *
Run Code Online (Sandbox Code Playgroud)

mymod/sub1/s1.py

"""s1 docstr"""
def sub1():
    """sub1 docstr"""
    return 3
Run Code Online (Sandbox Code Playgroud)

mymod/sub1/s2.py

"""s2 docstr"""
def sub2():
    """sub2 docstr"""
    return 4
Run Code Online (Sandbox Code Playgroud)

当我直接使用该模块时,它似乎按预期工作: …

python python-sphinx

5
推荐指数
1
解决办法
1636
查看次数

标签 统计

python ×1

python-sphinx ×1