构建符号链接背后的文档

构建符号链接背后的文档

我使用以下方式建立了一个内部文档网站MkDocs 的材料但我想通过将文件夹从其自己的 git 存储库符号链接到该docs/文件夹​​来提供多个项目自述文件。也就是说,给定两个项目:

  1. /home/user/projects/first_project.git其中有文档Guide/
  2. /projects/second_project.git其文献也有Guide/

我可以复制/home/user/projects/first_project/Guide到目录中docs/,它提供了必要的文档。

但由于我不想忘记rsync文件夹,所以我认为我应该对它们进行符号链接:

ln -s /home/user/projects/first_project/Guide docs/first_project_guide
ln -s /projects/second_project/Guide docs/second_project_guide

这让我可以在命令行中访问单独的指南文件夹,但 mkdocs 似乎不知道如何通过符号链接进行构建。有人知道如何配置 mkdocs 来做到这一点吗?

这是我看到的错误:

INFO    -  [01:57:11] Detected file changes
INFO    -  Building documentation...
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/mkdocs/livereload/__init__.py", line 193, in _build_loop
    func()
  File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/serve.py", line 67, in builder
    build(config, live_server=None if is_clean else server, dirty=is_dirty)
  File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/build.py", line 337, in build
    files.copy_static_files(dirty=dirty, inclusion=inclusion)
  File "/usr/local/lib/python3.11/site-packages/mkdocs/structure/files.py", line 111, in copy_static_files
    file.copy_file(dirty)
  File "/usr/local/lib/python3.11/site-packages/mkdocs/structure/files.py", line 290, in copy_file
    utils.copy_file(self.abs_src_path, self.abs_dest_path)
  File "/usr/local/lib/python3.11/site-packages/mkdocs/utils/__init__.py", line 132, in copy_file
    shutil.copyfile(source_path, output_path)
  File "/usr/local/lib/python3.11/shutil.py", line 256, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/docs/first_project_guide'

相关内容