Hi,
When writing documentation for OpenLayers, we are working on having our
documentation in multiple langauges. We are creating multiple files for
each piece of OpenLayers documentation:
index.rst
index.fr.rst
library/index.rst
library/index.fr.rst
Then, we are ilnking from index to library:
.. toctree::
library/index
We have enabled "MultiViews" on the Apache server, which means that
browsers which are configured to read French text can get French text by
going to:
/doc/index
/doc/library/index
However, it does not appear to be possible to have Sphinx generate a
file on disk named .html, and link to a file without that suffix, at
this time.
I would like to suggest that something along the lines of the attached
patch be applied, which adds support for an additional option to the
HTML writer, link_suffix. link_suffix is used to modify get_target_uri,
and defaults to matching output_suffix.
By setting output_suffix to .html, and link_suffix to '', we can achieve
the goals describe above with Sphinx.
This is my first time touching sphinx, so if my change is inappropriate
in some way, I apologize, and look forward to any feedback you might
offer.
Best Regards,
--
Christopher Schmidt
Web Developer
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sphinx-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---
diff -r ce3473e246a1 sphinx/builders/html.py
--- a/sphinx/builders/html.py Tue Dec 16 07:30:00 2008 +0100
+++ b/sphinx/builders/html.py Sat Dec 20 14:26:06 2008 -0500
@@ -49,6 +49,7 @@
name = 'html'
copysource = True
out_suffix = '.html'
+ link_suffix = '' # defaults to matching out_suffix
indexer_format = js_index
supported_image_types = ['image/svg+xml', 'image/png', 'image/gif',
'image/jpeg']
@@ -64,7 +65,12 @@
self.init_translator_class()
if self.config.html_file_suffix:
self.out_suffix = self.config.html_file_suffix
-
+
+ if self.config.html_link_suffix is not None:
+ self.link_suffix = self.config.html_link_suffix
+ else:
+ self.link_suffix = self.out_suffix
+
if self.config.language is not None:
jsfile = path.join(package_dir, 'locale', self.config.language,
'LC_MESSAGES', 'sphinx.js')
@@ -435,7 +441,7 @@
# --------- these are overwritten by the serialization builder
def get_target_uri(self, docname, typ=None):
- return docname + self.out_suffix
+ return docname + self.link_suffix
def handle_page(self, pagename, addctx, templatename='page.html',
outfilename=None, event_arg=None):
diff -r ce3473e246a1 sphinx/config.py
--- a/sphinx/config.py Tue Dec 16 07:30:00 2008 +0100
+++ b/sphinx/config.py Sat Dec 20 14:26:06 2008 -0500
@@ -72,6 +72,7 @@
html_show_sourcelink = (True, False),
html_use_opensearch = ('', False),
html_file_suffix = (None, False),
+ html_link_suffix = (None, False),
html_show_sphinx = (True, False),
html_context = ({}, False),
diff -r ce3473e246a1 sphinx/quickstart.py
--- a/sphinx/quickstart.py Tue Dec 16 07:30:00 2008 +0100
+++ b/sphinx/quickstart.py Sat Dec 20 14:26:06 2008 -0500
@@ -173,7 +173,14 @@
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
-# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml")
+# on disk.
+#html_file_suffix = ''
+
+# If set, this is the file name suffix for HTML files (e.g. ".xhtml")
+# in links. Setting this to '' will cause no suffix to be appended, which
+# allows for something like Apache's MultiViews to determine the correct
+# file to return.
#html_file_suffix = ''
# Output file base name for HTML help builder.