-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from apyb/github-issues
Link com referência para criação de issues no Github a partir de qualquer página
- Loading branch information
Showing
4 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from urllib.parse import urljoin | ||
from urllib.parse import urlencode | ||
|
||
|
||
def get_page_url(app, docname): | ||
site_base_url = app.config.html_baseurl | ||
document_uri = app.builder.get_relative_uri(app.builder.config.master_doc, docname) | ||
return urljoin(site_base_url, document_uri) | ||
|
||
|
||
def get_page_source_url(context, filepath): | ||
return "{source_url}/blob/{branch}/{dir}/{filepath}".format( | ||
source_url=context["source_url"], | ||
branch=context["source_branch"], | ||
dir=context["source_dir"], | ||
filepath=filepath, | ||
|
||
) | ||
|
||
|
||
def setup_github_issues_url(app, pagename, templatename, context, doctree): | ||
def github_issues_url(root_doc, pagename, page_source_suffix): | ||
if not root_doc or not page_source_suffix: | ||
return "" | ||
|
||
document_path = pagename + page_source_suffix | ||
|
||
page_url = get_page_url(app, pagename) | ||
page_source_url = get_page_source_url(context, document_path) | ||
|
||
|
||
source_url = context["source_url"] | ||
source_url = context["source_url"] | ||
|
||
new_issue_context = { | ||
"document_path": document_path, | ||
"page_url": page_url, | ||
"page_source_url": page_source_url, | ||
} | ||
|
||
new_issue_title = context["new_issue_title"].format_map(new_issue_context) | ||
new_issue_body = context["new_issue_body"].format_map(new_issue_context) | ||
url_params = urlencode({ | ||
"title": new_issue_title, | ||
"body": new_issue_body, | ||
}) | ||
|
||
return f"{source_url}/issues/new?{url_params}" | ||
|
||
context["github_issues_url"] = github_issues_url | ||
|
||
|
||
|
||
def setup(app): | ||
app.connect("html-page-context", setup_github_issues_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div class="sidebar-tree"> | ||
{{ furo_navigation_tree }} | ||
<p class="caption" role="heading"> | ||
<span class="caption-text"> | ||
Encontrou algum erro | ||
<br>ou tem alguma sugestão? | ||
</span> | ||
</p> | ||
<a href="{{ github_issues_url(root_doc, pagename, page_source_suffix) }}" style="color: #ff4e1b" target="blank" class="reference">Abra uma <i>issue</i> no Github</a> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters