Skip to content

Commit 336fe38

Browse files
authored
Merge pull request #24 from bigdata-ustc/docs
[BUILD] Initialization of the autodoc using sphinx
2 parents 65459a4 + 3bff51d commit 336fe38

32 files changed

+577
-55
lines changed

.github/workflows/python-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
python-version: ${{ matrix.python-version }}
2020
- name: Install dependencies
2121
run: |
22-
pip install -e .[test]
22+
pip install -e .[test,full]
2323
pip install codecov
2424
- name: Test with pytest
2525
run: |

.readthedocs.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# .readthedocs.yml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Build documentation in the docs/ directory with Sphinx
9+
sphinx:
10+
configuration: docs/source/conf.py
11+
12+
# Build documentation with MkDocs
13+
#mkdocs:
14+
# configuration: mkdocs.yml
15+
16+
# Optionally build your docs in additional formats such as PDF and ePub
17+
formats: []
18+
19+
# Optionally set the version of Python and requirements
20+
# required to build your docs
21+
python:
22+
version: 3.7
23+
install:
24+
- requirements: docs/requirements.txt
25+
- method: pip
26+
path: .
27+
extra_requirements:
28+
- full

EduNLP/Formula/ast/ast.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,18 @@ def ast(formula: (str, List[Dict]), index=0, forest_begin=0, father_tree=None, i
4141
4242
Notes
4343
----------
44-
Some functions are not supportd in katex
45-
eg :
44+
Some functions are not supportd in ``katex``
45+
e.g.,
46+
4647
1. tag
47-
'\\begin{equation} \\tag{tagName} F=ma \\end{equation}'
48-
'\\begin{align} \\tag{1} y=x+z \\end{align}'
49-
'\\tag*{hi} x+y^{2x}'
48+
- ``\\begin{equation} \\tag{tagName} F=ma \\end{equation}``
49+
- ``\\begin{align} \\tag{1} y=x+z \\end{align}``
50+
- ``\\tag*{hi} x+y^{2x}``
5051
2. dddot
51-
'\\frac{ \\dddot y }{ x }'
52-
3. see other: https://github.com/KaTeX/KaTeX/blob/master/docs/support_table.md
52+
- ``\\frac{ \\dddot y }{ x }``
53+
54+
For more information, refer to
55+
`katex support table <https://github.com/KaTeX/KaTeX/blob/master/docs/support_table.md>`_
5356
"""
5457
tree = []
5558
index += forest_begin

EduNLP/I2V/i2v.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,24 @@
1111

1212

1313
class I2V(object):
14+
"""
15+
16+
Parameters
17+
----------
18+
tokenizer: str
19+
the tokenizer name
20+
t2v: str
21+
the name of token2vector model
22+
args:
23+
the parameters passed to t2v
24+
tokenizer_kwargs: dict
25+
the parameters passed to tokenizer
26+
pretrained_t2v: bool
27+
kwargs:
28+
the parameters passed to t2v
29+
"""
1430
def __init__(self, tokenizer, t2v, *args, tokenizer_kwargs: dict = None, pretrained_t2v=False, **kwargs):
15-
"""
16-
17-
Parameters
18-
----------
19-
tokenizer: str
20-
the tokenizer name
21-
t2v: str
22-
the name of token2vector model
23-
args:
24-
the parameters passed to t2v
25-
tokenizer_kwargs: dict
26-
the parameters passed to tokenizer
27-
pretrained_t2v: bool
28-
kwargs:
29-
the parameters passed to t2v
30-
"""
31+
3132
self.tokenizer: Tokenizer = get_tokenizer(tokenizer, **tokenizer_kwargs if tokenizer_kwargs is not None else {})
3233
if pretrained_t2v:
3334
logger.info("Use pretrained t2v model %s" % t2v)
@@ -101,6 +102,18 @@ def from_pretrained(cls, name, model_dir=MODEL_DIR, *args, **kwargs):
101102

102103

103104
def get_pretrained_i2v(name, model_dir=MODEL_DIR):
105+
"""
106+
107+
Parameters
108+
----------
109+
name
110+
model_dir
111+
112+
Returns
113+
-------
114+
i2v model: I2V
115+
116+
"""
104117
if name not in MODELS:
105118
raise KeyError(
106119
"Unknown model name %s, use one of the provided models: %s" % (name, ", ".join(MODELS.keys()))

EduNLP/SIF/sif.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from .tokenization import tokenize, link_formulas
88
from .parser import Parser
99

10+
__all__ = ["is_sif", "to_sif", "sif4sci"]
11+
1012

1113
def is_sif(item):
1214
r"""

EduNLP/SIF/tokenization/text/stopwords.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from EduNLP.utils import abs_current_dir, path_append
66

77
DEFAULT_FILEPATH = os.path.abspath(
8-
path_append(abs_current_dir(__file__), "..", "..", "..", "..", "meta_data", "sif_stopwords.txt")
8+
path_append(abs_current_dir(__file__), "..", "..", "..", "meta_data", "sif_stopwords.txt")
99
)
1010

1111

EduNLP/SIF/tokenization/text/tokenization.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
jieba.setLogLevel(logging.INFO)
88

99

10-
def tokenize(text, granularity="word", stopwords=DEFAULT_STOPWORDS):
10+
def tokenize(text, granularity="word", stopwords="default"):
1111
"""
1212
1313
Parameters
1414
----------
1515
text
1616
granularity
17-
stopwords
17+
stopwords: str, None or set
1818
1919
Returns
2020
-------
@@ -26,6 +26,7 @@ def tokenize(text, granularity="word", stopwords=DEFAULT_STOPWORDS):
2626
>>> tokenize("三角函数是基本初等函数之一", granularity="char")
2727
['三', '角', '函', '数', '基', '初', '函', '数']
2828
"""
29+
stopwords = DEFAULT_STOPWORDS if stopwords == "default" else stopwords
2930
stopwords = stopwords if stopwords is not None else {}
3031
if granularity == "word":
3132
return [token for token in jieba.cut(text) if token not in stopwords and token.strip()]

EduNLP/SIF/tokenization/tokenization.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616

1717
class TokenList(object):
18+
"""
19+
Attributes
20+
-------------
21+
22+
"""
1823
def __init__(self, segment_list: SegmentList, text_params=None, formula_params=None, figure_params=None):
1924
self._tokens = []
2025
self._text_tokens = []
File renamed without changes.

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include EduNLP/meta_data *

0 commit comments

Comments
 (0)