diff --git a/.Jenkinsfile b/.Jenkinsfile new file mode 100644 index 00000000..b7dd29a0 --- /dev/null +++ b/.Jenkinsfile @@ -0,0 +1,45 @@ +pipeline { + agent { + docker { + image 'ubuntu_tester' + args '-u root:root -v ${HOME}/html/docs:/docs -v ${HOME}/html/_ci:/ci' + } + } + environment { + TRAVIS = 1 + PJ_NAME = 'fastNLP' + POST_URL = 'https://open.feishu.cn/open-apis/bot/v2/hook/14719364-818d-4f88-9057-7c9f0eaaf6ae' + } + stages { + stage('Package Installation') { + steps { + sh 'python setup.py install' + } + } + stage('Parallel Stages') { + parallel { + stage('Document Building') { + steps { + sh 'cd docs && make prod' + sh 'rm -rf /docs/${PJ_NAME}' + sh 'mv docs/build/html /docs/${PJ_NAME}' + } + } + stage('Package Testing') { + steps { + sh 'python -m spacy download en' + sh 'pip install fitlog' + sh 'pytest ./test --html=test_results.html --self-contained-html' + } + } + } + } + } + post { + always { + sh 'post' + } + + } + +} \ No newline at end of file diff --git a/docs/Makefile b/docs/Makefile index b41beb44..35306867 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -14,13 +14,16 @@ help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) apidoc: - $(SPHINXAPIDOC) -efM -o source ../$(SPHINXPROJ) && python3 format.py + $(SPHINXAPIDOC) -efM -o source ../$(SPHINXPROJ) server: cd build/html && python -m http.server dev: - rm -rf build && make html && make server + rm -f source/$(SPHINXPROJ).* source/modules.rst && rm -rf build && make apidoc && make html && make server + +prod: + make apidoc && make html .PHONY: help Makefile diff --git a/fastNLP/doc_utils.py b/fastNLP/doc_utils.py index 119db776..3f7889e4 100644 --- a/fastNLP/doc_utils.py +++ b/fastNLP/doc_utils.py @@ -23,9 +23,7 @@ def doc_process(m): while 1: defined_m = sys.modules[module_name] try: - if not hasattr(defined_m, "__all__"): - print("Warning: Module {} lacks `__all__`".format(module_name)) - elif "undocumented" not in defined_m.__doc__ and name in defined_m.__all__: + if "undocumented" not in defined_m.__doc__ and name in defined_m.__all__: obj.__doc__ = r"别名 :class:`" + m.__name__ + "." + name + "`" \ + " :class:`" + module_name + "." + name + "`\n" + obj.__doc__ break @@ -36,7 +34,7 @@ def doc_process(m): except: print("Warning: Module {} lacks `__doc__`".format(module_name)) break - + # 识别并标注基类,只有基类也在 fastNLP 中定义才显示 if inspect.isclass(obj): @@ -47,9 +45,7 @@ def doc_process(m): for i in range(len(parts) - 1): defined_m = sys.modules[module_name] try: - if not hasattr(defined_m, "__all__"): - print("Warning: Module {} lacks `__all__`".format(module_name)) - elif "undocumented" not in defined_m.__doc__ and name in defined_m.__all__: + if "undocumented" not in defined_m.__doc__ and name in defined_m.__all__: obj.__doc__ = r"基类 :class:`" + defined_m.__name__ + "." + base.__name__ + "` \n\n" + obj.__doc__ break module_name += "." + parts[i + 1]