Repository: googleapis/google-cloud-python

Issue:
Make it easy to open a documentation bug from the docs themselves
Maybe we can add paragraph level "report bug" links that link to the issues/new page?



Discussion:
Can we also link to the source of the document in the github edit UI so people can fix and send a PR?

@silvolu I seem to remember you doing something like this based on readthedocs ([example](http://docs.getpelican.com/en/3.5.0/)):

![screen_shot_054](https://cloud.githubusercontent.com/assets/520669/5754010/5496012c-9c47-11e4-9927-1bb686d74b35.png)

Did this happen in `gcloud-node`? I know it was [brought up](https://github.com/GoogleCloudPlatform/gcloud-node/pull/305#issuecomment-65839912) but I'm not sure if it ever came to be.

Doesn't appear that we've added this on gcloud-node yet either (
http://googlecloudplatform.github.io/gcloud-node/#/docs/v0.12.0/datastore/transaction
)

We have an "Edit on GitHub" link on the two pages that are generated from MD: https://googlecloudplatform.github.io/gcloud-node/#/faq and https://googlecloudplatform.github.io/gcloud-node/#/troubleshooting

For reference, my [comment](https://github.com/GoogleCloudPlatform/gcloud-python/pull/625#issuecomment-74167700) on the version fix (for #472) points out where to put something like this.

Made a comment on another bug, but putting it here for reference:

> I think it's important that if I scroll far down into a section of the docs, and see a problem with a specific thing (ie, say the note on http://googlecloudplatform.github.io/gcloud-python/storage-blobs.html#gcloud.storage.blob.Blob.upload_from_file), I shouldn't have to scroll all the way back up -- I'd want to click "edit" right there and be taken to the right place...

Any chance we can do that? Maybe have the issue body pre-filled with the method that has the issue?

I'll also port over my comment:

> We could put the "file docs bug" in our Big Blue Bar(TM) which stays fixed at the top of each page.

As for pre-filling issue body, I'd have to learn a bit more about what GitHub allows.

UPDATE: That was easy https://github.com/GoogleCloudPlatform/gcloud-python/issues/new?title=foo&body=bar

@jgeewax WDYT of:

![screen_shot_066](https://cloud.githubusercontent.com/assets/520669/6193858/0e94fd60-b374-11e4-8609-4e3dd267ba37.png)

This also drops "Python" from #538, though I noticed `Node.js` is the title in node land.

This becomes an issue when the nav gets collapsed when page width goes down i.e. for mobile (responsive web dev).

![screen_shot_067](https://cloud.githubusercontent.com/assets/520669/6193915/79232760-b374-11e4-9aef-7365333a5d83.png)

Would you like to see "Report an Issue" folded into the nav hamburger (3 stacked white bars on RHS) or somewhere else?

If we can't pre-populate the bug text with anything (ie, "method was ....") then this is great -- and we just need some responsive tweaks.

Pre-populating will be possible. E.g.:

https://github.com/GoogleCloudPlatform/gcloud-python/issues/new?body=Commit%3A%2008fae45%0APage%3A%20http%3A%2F%2Fgooglecloudplatform.github.io%2Fgcloud-python%2Flatest%2Fdatastore-entities.html

Need to get #624 and #625 in before though so we don't have conflicting things flying by

UPDATE: 
1. Having the source is not always possible since the docs are generated from RST. We might be able to map it though?
2. We'd need to embed the commit hash in ever page as a data attribute, but that's easy enough to do

An [example](https://github.com/bitprophet/alabaster/blob/a46b19cf8b612b8798e7f5961ff9e466e349f7bd/alabaster/layout.html#L18-L23) for getting the source path in our template:

``` html
      {%- if show_source and has_source and sourcename %}
      |
      <a href="{{ pathto('_sources/' + sourcename, true)|e }}"
          rel="nofollow">{{ _('Page source') }}</a></li>
      {%- endif %}
```

The Sphinx [docs](http://sphinx-doc.org/templating.html#show_source) also describe what `show_source` is (but I find their docs a bit unparseable).


Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -13,6 +13,7 @@
 
 from pkg_resources import get_distribution
 import sys, os
+import urllib
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -179,6 +180,8 @@
 # Output file base name for HTML help builder.
 htmlhelp_basename = 'gclouddoc'
 
+html_context = {}
+
 
 # -- Options for LaTeX output --------------------------------------------------
 
@@ -257,3 +260,14 @@
 # This pulls class descriptions from the class docstring,
 # and parameter definitions from the __init__ docstring.
 autoclass_content = 'both'
+
+issue_uri = ('https://github.com/GoogleCloudPlatform/gcloud-python/issues/'
+             'new?' + urllib.urlencode({'title': '[Documentation Issue] '}))
+issue_uri_template = (
+    issue_uri + '&' + urllib.urlencode({'body': 'Page Name: '}) + '{0}' +
+    urllib.quote('\nRelease: ') + '{1}')
+
+html_context.update(
+    issue_uri=issue_uri,
+    issue_uri_template=issue_uri_template,
+)


Test patch: