Logo

Getting started

  • Tutorial
  • 增添文件專案
  • 熱門文件工具
  • 範例專案

專案設定與組態

  • Configuration file overview
  • Configuration file reference
  • Read the Docs Addons
  • Account authentication methods
  • Automation rules
  • How to create reproducible builds

Build process

  • Build process overview
  • Build process customization
  • Git integration (GitHub, GitLab, Bitbucket)
  • 拉取請求預覽
  • 建置失敗通知
  • 環境變數概覽
  • 環境變數參考

託管文件

  • Versions
  • 子專案
  • 在地化與國際化
  • URL versioning schemes
  • 自訂域名
  • URL path prefixes
  • 文件通知
  • Canonical URLs
  • Content Delivery Network (CDN) and caching
  • Sitemap support
  • 404 Not Found pages
  • robots.txt support
  • llms.txt support

閱讀文件

  • Offline formats (PDF, ePub, HTML)
  • Visual diff
  • 連結預覽
  • How to embed content from your documentation
  • Server side search
  • 搜尋查詢語法
  • 飛出式選單

維護專案

  • Redirects
  • Traffic analytics
  • Search analytics
  • Security logs
  • 狀態徽章
  • How to structure your documentation
  • Best practices for linking to your documentation
  • Security considerations for documentation pages
  • Main content detection
  • AI agent skills
  • Custom script

Business features

  • Business hosting
  • Organizations
  • 單一登入(SSO)
  • Sharing private documentation
  • 如何管理您的訂閱
  • Privacy levels

操作指南

  • 專案設定與組態
  • Build process
  • Upgrading and maintaining projects
  • Content, themes and SEO
    • Search engine optimization (SEO) for documentation projects
    • Using traffic analytics
    • Using search analytics
    • Enabling offline formats
    • Embedding content from your documentation
    • Managing translations for Sphinx projects
    • Supporting Unicode in Sphinx PDFs
    • Cross-referencing with Sphinx
    • Linking to other projects with Intersphinx
    • Using Jupyter notebooks in Sphinx
    • 從 rST 遷移到 MyST
    • Adding custom CSS or JavaScript to Sphinx documentation
    • Adding "Edit Source" links on your Sphinx theme
      • GitHub
      • Bitbucket
      • Gitlab
      • Additional variables
  • Security and access
  • 帳號管理
  • 最佳實踐
  • Troubleshooting problems

Reference

  • Public REST API
  • 常見問題集
  • 變更日誌
  • 關於 Read the Docs
  • 開發者文件
  • Read the Docs 網站
Read the Docs user documentation
  • How-to guides: content, themes and SEO
  • Adding "Edit Source" links on your Sphinx theme
  • Edit on GitHub

Adding "Edit Source" links on your Sphinx theme

You can use define some Sphinx variables in the html_context to tell Read the Docs Sphinx theme to display "Edit Source" links on each page.

More information can be found on Sphinx documentation.

GitHub

If you want to integrate GitHub, these are the required variables to put into your conf.py:

html_context = {
    "display_github": True, # Integrate GitHub
    "github_user": "MyUserName", # Username
    "github_repo": "MyDoc", # Repo name
    "github_version": "master", # Version
    "conf_py_path": "/source/", # Path in the checkout to the docs root
}

They can be used like this:

{% if display_github %}
    <li><a href="https://github.com/{{ github_user }}/{{ github_repo }}
    /blob/{{ github_version }}{{ conf_py_path }}{{ pagename }}.rst">
    Show on GitHub</a></li>
{% endif %}

Bitbucket

If you want to integrate Bitbucket, these are the required variables to put into your conf.py:

html_context = {
    "display_bitbucket": True, # Integrate Bitbucket
    "bitbucket_user": "MyUserName", # Username
    "bitbucket_repo": "MyDoc", # Repo name
    "bitbucket_version": "master", # Version
    "conf_py_path": "/source/", # Path in the checkout to the docs root
}

They can be used like this:

{% if display_bitbucket %}
    <a href="https://bitbucket.org/{{ bitbucket_user }}/{{ bitbucket_repo }}
    /src/{{ bitbucket_version}}{{ conf_py_path }}{{ pagename }}.rst'"
    class="icon icon-bitbucket"> Edit on Bitbucket</a>
{% endif %}

Gitlab

If you want to integrate Gitlab, these are the required variables to put into your conf.py:

html_context = {
    "display_gitlab": True, # Integrate Gitlab
    "gitlab_user": "MyUserName", # Username
    "gitlab_repo": "MyDoc", # Repo name
    "gitlab_version": "master", # Version
    "conf_py_path": "/source/", # Path in the checkout to the docs root
}

They can be used like this:

{% if display_gitlab %}
    <a href="https://{{ gitlab_host|default("gitlab.com") }}/
    {{ gitlab_user }}/{{ gitlab_repo }}/blob/{{ gitlab_version }}
    {{ conf_py_path }}{{ pagename }}{{ suffix }}" class="fa fa-gitlab">
    Edit on GitLab</a>
{% endif %}

Additional variables

  • 'pagename' - Sphinx variable representing the name of the page you're on.

Previous Next

© Copyright Read the Docs, Inc & contributors.

Built with Sphinx using a theme provided by Read the Docs.