Skip to content

Commit 023f070

Browse files
authored
fix chinese doc bug (#883)
1 parent 7a8eb94 commit 023f070

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ jobs:
7676
- name: Run DocCheck
7777
run: |
7878
pip install -r tests/requirements.txt
79-
pytest --lf --durations=0 -v tests/doc_check
80-
LAZYLLM_LANGUAGE=CHINESE pytest --lf --durations=0 -v tests/doc_check
79+
pytest -v tests/doc_check
80+
git checkout .
81+
LAZYLLM_LANGUAGE=CHINESE pytest -v tests/doc_check
82+
git checkout .
8183
8284
clone:
8385
if: |

lazyllm/docs/common.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@
6262
group_name (str): The name of the group to be created.
6363
''')
6464

65+
66+
add_chinese_doc('Register.new_group', '''\
67+
创建一个新的ComponentGroup。新建的group会自动加入到__builtin__中,无需import即可在任一位置访问到该group。
68+
69+
Args:
70+
group_name (str): 待创建的group的名字
71+
''')
72+
73+
6574
# add_example('Register', '''\
6675
# >>> import lazyllm
6776
# >>> @lazyllm.component_register('mygroup')

lazyllm/docs/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import threading
44
from typing import Tuple
55

6+
lazyllm.config.add('raise_on_add_doc_error', bool, False, 'RAISE_ON_ADD_DOC_ERROR',
7+
description='Whether to raise an error when adding doc failed.')
8+
69
cpp_add_doc_code = '''
710
namespace py = pybind11;
811
void addDocStr(py::object obj, std::string docs) {
@@ -91,7 +94,8 @@ def add_doc(obj_name, docstr, module, append=''):
9194
else:
9295
obj.__doc__ = docstr
9396
except Exception:
94-
raise NotImplementedError('Cannot add doc for builtin class or method now, will be supported in the feature')
97+
if lazyllm.config['raise_on_add_doc_error']:
98+
raise RuntimeError(f'Failed to add doc for {obj_name} in {module.__name__}')
9599

96100

97101
def add_chinese_doc(obj_name, docstr, module=lazyllm):

0 commit comments

Comments
 (0)