1

整个项目的链接https://gitlab.com/ComplicatedPhenomenon/doubancrawler

我在本地机器上测试了生成的文档,它工作正常 在此处输入图像描述

和gitlab页面如下(https://complicatedphenomenon.gitlab.io/doubancrawler/api.html在此处输入图像描述

有什么问题.gitlab-ci.yml吗?

image: python:3.7-alpine

test:
  stage: test
  script:
  - pip install -r requirements2.txt
  - cd docs/source/
  - sphinx-build -b html . public
  - mv public ../..
  only:
  - branches
  except:
  - master

pages:
  stage: deploy
  script:
  - pip install -r requirements2.txt
  - cd docs/source/
  - sphinx-build -b html . public
  - mv public ../..
  artifacts:
    paths:
    - public
  only:
  - master
4

1 回答 1

2

当 autodoc 无法找到/导入您的参考文献时,就会发生这种情况。

您没有安装项目的所有要求。为了使 autodoc 工作,您需要能够导入所有包模块。但是,您只是安装构建文档的要求 (requirements2.txt)。

否则,当您的模块尝试导入未安装的包时,autodoc 将ImportError在尝试提取您的文档字符串时收到一个提示。

在本地,您可能没有问题,因为您已经安装了所有需求。

要解决此问题,请添加pip install -r requirements.txt到您的工作中。

于 2021-12-18T20:32:22.547 回答