forked from cakephp/docs
-
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.
Adding a new sphinx extension for the CakePHP i18n links.
These provide inter-doc links for the various translations of the docs.
- Loading branch information
Showing
2 changed files
with
37 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
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,28 @@ | ||
from sphinx.util.osutil import SEP, os_path, relative_uri | ||
import pprint | ||
""" | ||
CakePHP i18n extension. | ||
A simple sphinx extension for adding | ||
i18n links to other sub doc projects. | ||
""" | ||
|
||
def setup(app): | ||
app.connect('html-page-context', append_template_ctx) | ||
app.add_config_value('languages', [], '') | ||
return app | ||
|
||
def append_template_ctx(app, pagename, templatename, ctx, event_arg): | ||
def langlink(lang, path): | ||
""" | ||
Generates links to other language docs. | ||
""" | ||
dots = [] | ||
for p in path.split(SEP): | ||
dots.append('..') | ||
return SEP.join(dots) + SEP + lang + SEP + path + app.builder.link_suffix | ||
|
||
ctx['langlink'] = langlink | ||
# pprint.pprint(app.config.__dict__) | ||
ctx['languages'] = app.config.languages | ||
ctx['language'] = app.config.language |