Python 如何将Sphinx Makefile集成到现有的项目Makefile中?

Python 如何将Sphinx Makefile集成到现有的项目Makefile中?,python,makefile,python-sphinx,Python,Makefile,Python Sphinx,我有一个具有以下目录结构的现有项目: docs/ conf.py Makefile index.rst documentation-foo.rst documentation-bar.rst src/ ...code... common.mk Makefile README.rst 在存储库的根目录中,Makefile包含与代码的生成、测试、打包和部署相关的各种有用命令。类似地,common.mk包括一项检查,以确保用户的系统上有几个可用的实用程

我有一个具有以下目录结构的现有项目:

docs/
    conf.py
    Makefile
    index.rst
    documentation-foo.rst
    documentation-bar.rst
src/
    ...code...
common.mk
Makefile
README.rst
在存储库的根目录中,
Makefile
包含与代码的生成、测试、打包和部署相关的各种有用命令。类似地,
common.mk
包括一项检查,以确保用户的系统上有几个可用的实用程序(例如,
jq
用于操作/显示JSON),这些程序不能与
pip一起安装。我可以发出诸如
makelint
maketest
之类的命令,这些命令在该Makefile中定义。(
Makefile
的顶部还有一个
include common.mk
,Makefile的内容见下文。)

docs/
文件夹中,Sphinx会自动生成
Makefile
。此Makefile是独立的,完全独立于存储库根目录中的Makefile或common.mk文件。我可以发出类似
makehtml
的命令,它将使用Sphinx生成html格式的文档

(根)/Makefile的内容:

include common.mk

clean:
    ...

lint:
    ...

test:
    ....
ifeq ($(shell which jq),)
$(error Please install jq using "apt-get install jq" or "brew install jq")
endif
# Minimal makefile for Sphinx documentation
SPHINXOPTS    ?=
SPHINXBUILD   ?= sphinx-build
...
(root)/common.mk的内容:

include common.mk

clean:
    ...

lint:
    ...

test:
    ....
ifeq ($(shell which jq),)
$(error Please install jq using "apt-get install jq" or "brew install jq")
endif
# Minimal makefile for Sphinx documentation
SPHINXOPTS    ?=
SPHINXBUILD   ?= sphinx-build
...
(斯芬克斯)的内容/docs/Makefile

include common.mk

clean:
    ...

lint:
    ...

test:
    ....
ifeq ($(shell which jq),)
$(error Please install jq using "apt-get install jq" or "brew install jq")
endif
# Minimal makefile for Sphinx documentation
SPHINXOPTS    ?=
SPHINXBUILD   ?= sphinx-build
...
我的主要问题是:如何合并位于
/docs/Makefile
的sphinx Makefile中的规则,以便从根级别
/Makefile
获取这些规则?

例如,要制作HTML文档,我当前必须从repo的根目录
cd docs&&make HTML
,但我希望能够从回购协议的根目录运行
makehtml
,并让回购协议根目录中的Makefile将目标解析为
docs/Makefile
中定义的
html
目标,并使用该Makefile中定义的规则

第二个相关问题:如果我在
docs/Makefile
中有具有相对路径的命令,那么路径必须更新为相对于运行
make
命令的位置(repo的根而不是
docs/
),或者
make
是否将相对链接解析为相对于
docs/
中Makefile的位置?

您可以使用:

有些人非常不喜欢递归制造。你可以阅读,但我认为它们不适用于make的使用,因为你不想表达依赖关系