You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2013/07/24 14:24:56 UTC
[19/50] [abbrv] git commit: updated
refs/heads/1781-reorganize-and-improve-docs to fa11c25
Provide quick links to show and edit docs on GitHub.
Thanks Marius for his extension.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/485d001d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/485d001d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/485d001d
Branch: refs/heads/1781-reorganize-and-improve-docs
Commit: 485d001d98f51fdd21caafef8055385e10897d22
Parents: 2c74795
Author: Alexander Shorin <kx...@apache.org>
Authored: Tue Jul 23 14:55:09 2013 +0400
Committer: Alexander Shorin <kx...@apache.org>
Committed: Wed Jul 24 10:48:37 2013 +0400
----------------------------------------------------------------------
share/doc/build/Makefile.am | 6 +++++-
share/doc/ext/github.py | 44 ++++++++++++++++++++++++++++++++++++++
share/doc/src/conf.py | 17 +++++++++++----
share/doc/templates/help.html | 8 +++++++
4 files changed, 70 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/485d001d/share/doc/build/Makefile.am
----------------------------------------------------------------------
diff --git a/share/doc/build/Makefile.am b/share/doc/build/Makefile.am
index c822195..ed8ef6c 100644
--- a/share/doc/build/Makefile.am
+++ b/share/doc/build/Makefile.am
@@ -196,13 +196,17 @@ src_files_html = \
../templates/searchbox.html \
../templates/utilities.html
+sphinx_extensions = \
+ ../ext/github.py
+
EXTRA_DIST = \
$(image_files) \
$(src_files) \
$(src_files_html) \
$(info_file_build) \
$(pdf_file_build) \
- $(html_files_build)
+ $(html_files_build) \
+ $(sphinx_extensions)
BUILT_SOURCES = \
$(info_file_build) \
http://git-wip-us.apache.org/repos/asf/couchdb/blob/485d001d/share/doc/ext/github.py
----------------------------------------------------------------------
diff --git a/share/doc/ext/github.py b/share/doc/ext/github.py
new file mode 100644
index 0000000..79bc193
--- /dev/null
+++ b/share/doc/ext/github.py
@@ -0,0 +1,44 @@
+## Licensed under the Apache License, Version 2.0 (the "License"); you may not
+## use this file except in compliance with the License. You may obtain a copy of
+## the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+## License for the specific language governing permissions and limitations under
+## the License.
+
+import os
+
+
+def get_github_url(app, view, path):
+ return 'https://github.com/{project}/{view}/{branch}/{path}'.format(
+ project=app.config.github_project,
+ view=view,
+ branch=app.config.github_branch,
+ path=path)
+
+
+def html_page_context(app, pagename, templatename, context, doctree):
+ # base template for common sphinx pages like search or genindex
+ # there is no need to provide github show/edit links for them
+ if templatename != 'page.html':
+ return
+
+ # ok, I'm aware about that this is wrong way to concat url segments
+ # but this is one is most portable between 2.x and 3.x versions
+ # plus it fits our current requirements. But still, patches are welcome (:
+ path = os.path.join(
+ app.config.github_docs_path,
+ os.path.relpath(doctree.get('source'), app.builder.srcdir))
+ context['github_show_url'] = get_github_url(app, 'blob', path)
+ context['github_edit_url'] = get_github_url(app, 'edit', path)
+
+
+def setup(app):
+ app.add_config_value('github_project', '', True)
+ app.add_config_value('github_branch', 'master', True)
+ app.add_config_value('github_docs_path', '', True)
+ app.connect('html-page-context', html_page_context)
http://git-wip-us.apache.org/repos/asf/couchdb/blob/485d001d/share/doc/src/conf.py
----------------------------------------------------------------------
diff --git a/share/doc/src/conf.py b/share/doc/src/conf.py
index 6fd9112..396c6a9 100644
--- a/share/doc/src/conf.py
+++ b/share/doc/src/conf.py
@@ -10,9 +10,12 @@
## License for the specific language governing permissions and limitations under
## the License.
-import sys, os
+import os
+import sys
-extensions = ["sphinx.ext.todo", "sphinx.ext.extlinks"]
+sys.path.insert(0, os.path.abspath('../ext'))
+
+extensions = ["sphinx.ext.todo", "sphinx.ext.extlinks", 'github']
source_suffix = ".rst"
@@ -46,7 +49,7 @@ html_logo = "../images/logo.png"
html_favicon = "../images/favicon.ico"
-html_sidebars= {
+html_sidebars = {
"**": [
"searchbox.html",
"localtoc.html",
@@ -68,7 +71,7 @@ latex_documents = [(
)]
latex_elements = {
- "papersize":"a4paper"
+ "papersize": "a4paper"
}
texinfo_documents = [(
@@ -86,3 +89,9 @@ extlinks = {
'issue': ('https://issues.apache.org/jira/browse/COUCHDB-%s', 'COUCHDB-'),
'commit': ('https://git-wip-us.apache.org/repos/asf?p=couchdb.git;a=commit;h=%s', '#')
}
+
+github_project = 'apache/couchdb'
+
+github_branch = 'master'
+
+github_docs_path = 'share/doc/src'
http://git-wip-us.apache.org/repos/asf/couchdb/blob/485d001d/share/doc/templates/help.html
----------------------------------------------------------------------
diff --git a/share/doc/templates/help.html b/share/doc/templates/help.html
index 67b0e50..fcc75c5 100644
--- a/share/doc/templates/help.html
+++ b/share/doc/templates/help.html
@@ -21,4 +21,12 @@ specific language governing permissions and limitations under the License.
<li><a href="https://couchdb.apache.org/#mailing-list">Mailing Lists</a></li>
<li><a href="http://webchat.freenode.net/?channels=couchdb">IRC</a></li>
<li><a href="https://issues.apache.org/jira/browse/CouchDB">Issues</a></li>
+{%- if github_show_url %}
+<li><a href="{{ github_show_url }}"
+ rel="nofollow">{{ _('Show on GitHub') }}</a></li>
+{%- endif %}
+{%- if github_edit_url %}
+<li><a href="{{ github_edit_url }}"
+ rel="nofollow">{{ _('Edit on GitHub') }}</a></li>
+{%- endif %}
</ul>