如何从项目文档创建 GitHub 页面?

发布于 2024-11-15 11:06:38 字数 332 浏览 4 评论 0原文

我在 GitHub 上有一个项目,其中包含一些自动生成的 HTML 文档的目录。我想在 GitHub 的项目页面工具中使用该文档。

因此,我已阅读有关如何创建项目的 gh-pages 根分支的说明。这有效地创建了一个空分支。

我想要帮助的是从 master 分支镜像 /docs 路径中的 html 文件,因此它们位于 gh-pages 的根目录中 分支。解决这个问题的最佳方法是什么?

I have a project on GitHub that has a directory containing some automatically generated HTML documentation. I would like to use that documentation within GitHub's project pages facility.

So, I've read the instructions on how to create the project's gh-pages root branch. This effectively creates an empty branch.

What I'd like help with is mirroring the html files in the /docs path from the master branch, so they are in the root of the gh-pages branch. What is the best way of approaching this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紫南 2024-11-22 11:06:38

在这里回答我自己的问题...已经通过 Git 子模块实现了我想要的目标。

我基本上复制了此清酒任务中详细说明的内容 ,但总而言之:

  • docs 路径移至临时文件夹中。提交更改。
  • 按照通常说明创建了一个干净的gh-pages分支,
  • 将所有内容从将临时文件夹复制到新的 gh-pages 分支中。提交更改。
  • 返回 master 分支,将远程 gh-pages 添加为 docs 文件夹中的子模块。
  • 提交更改。瞧!

Answering my own question here... have achieved what I wanted with Git submodules.

I basically copied what's detailed in this sake task, but in summary:

  • Moved the docs path into a temp folder. Commit changes.
  • Created a clean gh-pages branch as per the usual instructions
  • Moved everything from the temp folder into the new gh-pages branch. Commit changes.
  • Back in the master branch, add the remote gh-pages as a submodule in the docs folder.
  • Commit changes. Voila!
如痴如狂 2024-11-22 11:06:38

嗯,我最终编写了这两个 Makefile 目标来推送我的文档。我只是做了 update-doc 并且它通常有效。

TMP_PATH="/tmp/some_path"

## the dir containing HTML docs to push to gh-pages
HTML_DIR="html"

## arbitrary dirs created by the doc build system that should be removed
TRASH=latex

update-doc: doc
        rm -rf ${TMP_PATH} && cp ${HTML_DIR} ${TMP_PATH} -R && rm -rf ${HTML_DIR}
        git fetch
        git checkout gh-pages
        cp ${TMP_PATH}/* . -R
        rm -rf ${TRASH}
        git add .
        git commit -m "Update documentation"
        git push -u origin gh-pages
        rm -rf ${TMP_PATH}
        git checkout master

# command to build documentation; can be customised but
# remember to also change the HTML_DIR and TRASH variables
doc:
        doxygen docs/doxygen.conf

.PHONY: doc update-doc

我使用 doxygen,但您可以将其更改为任何其他文档系统。

这假设远程上存在 gh-pages 分支,并且是按照 这里

Mhm, I ended up writing these two Makefile targets to push my docs. I just do make update-doc and it generally works.

TMP_PATH="/tmp/some_path"

## the dir containing HTML docs to push to gh-pages
HTML_DIR="html"

## arbitrary dirs created by the doc build system that should be removed
TRASH=latex

update-doc: doc
        rm -rf ${TMP_PATH} && cp ${HTML_DIR} ${TMP_PATH} -R && rm -rf ${HTML_DIR}
        git fetch
        git checkout gh-pages
        cp ${TMP_PATH}/* . -R
        rm -rf ${TRASH}
        git add .
        git commit -m "Update documentation"
        git push -u origin gh-pages
        rm -rf ${TMP_PATH}
        git checkout master

# command to build documentation; can be customised but
# remember to also change the HTML_DIR and TRASH variables
doc:
        doxygen docs/doxygen.conf

.PHONY: doc update-doc

I use doxygen but you could change this to whatever other documentation system.

This assumes the gh-pages branch exists on the remote and was created as explained here.

一江春梦 2024-11-22 11:06:38

为这些文件创建到该位置的符号链接。您也应该能够做出这些承诺。

create symlinks for those files to that spot. You should be able to commit those too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文