From fcda5a7f1434da8df0b14af72bd223429fc0b59d Mon Sep 17 00:00:00 2001 From: Erik Bernoth Date: Tue, 6 Aug 2013 14:24:13 +0200 Subject: Makes the config value for latex doc classes more flexible. --- sphinx/writers/latex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index a9e98abf..cd6cce9b 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -179,7 +179,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.elements = self.default_elements.copy() self.elements.update({ - 'wrapperclass': 'sphinx' + document.settings.docclass, + 'wrapperclass': document.settings.docclass, 'papersize': papersize, 'pointsize': builder.config.latex_font_size, # if empty, the title is set to the first section title -- cgit v1.2.1 From f0477fc45d29d8dd8089f4d63b85cc8007d78cc8 Mon Sep 17 00:00:00 2001 From: Erik Bernoth Date: Fri, 20 Sep 2013 11:45:56 +0200 Subject: Conditional prefix prepending for docclasses To remove the prefix for document classes completely is not necessary. Old style config files can still work if there is a corresponding condition which prepends 'sphinx' only when the configured document class is one of the Sphinx specific classes. --- sphinx/writers/latex.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index cd6cce9b..b465a2f8 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -167,6 +167,9 @@ class LaTeXTranslator(nodes.NodeVisitor): 'transition': '\n\n\\bigskip\\hrule{}\\bigskip\n\n', } + # sphinx specific document classes + docclasses = ('howto', 'manual') + def __init__(self, document, builder): nodes.NodeVisitor.__init__(self, document) self.builder = builder @@ -179,7 +182,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.elements = self.default_elements.copy() self.elements.update({ - 'wrapperclass': document.settings.docclass, + 'wrapperclass': self.format_docclass(document.settings.docclass), 'papersize': papersize, 'pointsize': builder.config.latex_font_size, # if empty, the title is set to the first section title @@ -276,6 +279,13 @@ class LaTeXTranslator(nodes.NodeVisitor): self.previous_spanning_column = 0 self.remember_multirow = {} + def format_docclass(self, docclass): + """ prepends prefix to sphinx document classes + """ + if docclass in self.docclasses: + docclass = 'sphinx' + docclass + return docclass + def astext(self): return (HEADER % self.elements + self.highlighter.get_stylesheet() + -- cgit v1.2.1 From 961a119d5075390c8ed9b590e7479d4e1337cc12 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sat, 21 Sep 2013 07:55:37 +0000 Subject: add link to IRC channel --- doc/develop.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/develop.rst b/doc/develop.rst index 4181cde8..fad5982e 100644 --- a/doc/develop.rst +++ b/doc/develop.rst @@ -11,6 +11,7 @@ Sphinx is a maintained by a group of volunteers. We value every contribution! `_. * The mailing list for development is at `Google Groups `_. +* There is also #sphinx-doc IRC channel on `freenode `_. For more about our development process and methods, see the :doc:`devguide`. -- cgit v1.2.1 From cada2f472194af4a5d09dbd3ebb330fb13a74671 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Mon, 23 Sep 2013 09:57:36 +0900 Subject: fix: test_build_latex and test_build_texinfo raise SkipTest if command missing. Closes #1184. --- tests/test_build_latex.py | 2 +- tests/test_build_texinfo.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 50aef045..016c7aae 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -86,7 +86,7 @@ def test_latex(app): p = Popen(['pdflatex', '--interaction=nonstopmode', 'SphinxTests.tex'], stdout=PIPE, stderr=PIPE) except OSError: - pass # most likely pdflatex was not found + raise SkipTest # most likely pdflatex was not found else: stdout, stderr = p.communicate() if p.returncode != 0: diff --git a/tests/test_build_texinfo.py b/tests/test_build_texinfo.py index eb60fb8f..bf3cc49f 100644 --- a/tests/test_build_texinfo.py +++ b/tests/test_build_texinfo.py @@ -17,7 +17,7 @@ from subprocess import Popen, PIPE from sphinx.writers.texinfo import TexinfoTranslator -from util import with_app, test_root, remove_unicode_literals +from util import test_root, SkipTest, remove_unicode_literals, with_app from test_build_html import ENV_WARNINGS @@ -56,7 +56,7 @@ def test_texinfo(app): p = Popen(['makeinfo', '--no-split', 'SphinxTests.texi'], stdout=PIPE, stderr=PIPE) except OSError: - pass # most likely makeinfo was not found + raise SkipTest # most likely makeinfo was not found else: stdout, stderr = p.communicate() retcode = p.returncode -- cgit v1.2.1 From 09eec633e6c92af34ebccf4aa859b28774c35494 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Mon, 23 Sep 2013 19:53:22 +0900 Subject: Fix i18n: crash when translating section name that is pointed from named target. Closes #1265 --- CHANGES | 16 ++++++++++++++++ sphinx/transforms.py | 7 +++++++ tests/roots/test-intl/label_target.po | 6 ++++++ tests/roots/test-intl/label_target.txt | 12 +++++++++++- tests/test_intl.py | 10 +++++++++- 5 files changed, 49 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 2207ba30..44a246bf 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,19 @@ +Release 1.2 (in development) +============================ + +Features added +-------------- + +Incompatible changes +-------------------- + +Bugs fixed +---------- + +* #1265: Fix i18n: crash when translating section name that is pointed from + named target. + + Release 1.2 beta2 (released Sep 17, 2013) ========================================= diff --git a/sphinx/transforms.py b/sphinx/transforms.py index cf1040cf..338d4739 100644 --- a/sphinx/transforms.py +++ b/sphinx/transforms.py @@ -242,6 +242,13 @@ class Locale(Transform): self.document.note_implicit_target( section_node, section_node) + # replace target's refname to new target name + def is_named_target(node): + return isinstance(node, nodes.target) and \ + node.get('refname') == old_name + for old_target in self.document.traverse(is_named_target): + old_target['refname'] = new_name + processed = True # glossary terms update refid diff --git a/tests/roots/test-intl/label_target.po b/tests/roots/test-intl/label_target.po index 2e600f6d..69844016 100644 --- a/tests/roots/test-intl/label_target.po +++ b/tests/roots/test-intl/label_target.po @@ -50,3 +50,9 @@ msgid "" msgstr "" "`X DUPLICATED SUB SECTION`_ IS BROKEN LINK." +msgid "label bridged target section" +msgstr "X LABEL BRIDGED TARGET SECTION" + +msgid "`bridge label`_ is not translatable but linked to translated section title." +msgstr "X `bridge label`_ IS NOT TRANSLATABLE BUT LINKED TO TRANSLATED SECTION TITLE." + diff --git a/tests/roots/test-intl/label_target.txt b/tests/roots/test-intl/label_target.txt index b597abe7..635de847 100644 --- a/tests/roots/test-intl/label_target.txt +++ b/tests/roots/test-intl/label_target.txt @@ -47,8 +47,18 @@ duplicated sub section ------------------------ .. This section have no label, but the section was a duplicate name. -.. THis case, a duplicated target id is generated by docutils. +.. This case, a duplicated target id is generated by docutils. .. There is no way to link to this section's duplicated id like ``id2`` by .. using formal reStructuredText markup. + +.. _bridge label: `label bridged target section`_ + +label bridged target section +============================= + +.. This section is targeted through label definition. + +`bridge label`_ is not translatable but linked to translated section title. + diff --git a/tests/test_intl.py b/tests/test_intl.py index 67ab9578..13cdc84a 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -420,7 +420,7 @@ def test_i18n_role_xref(app): @with_intl_app(buildername='xml', warning=warnfile) def test_i18n_label_target(app): - # regression test for #1193 + # regression test for #1193, #1265 app.builder.build(['label_target']) et = ElementTree.parse(app.outdir / 'label_target.xml') secs = et.findall('section') @@ -455,6 +455,14 @@ def test_i18n_label_target(app): texts=['`X DUPLICATED SUB SECTION`_', 'IS BROKEN LINK.'], refs=[]) + para3 = secs[3].findall('paragraph') + assert_elem( + para3[0], + texts=['X', 'bridge label', + 'IS NOT TRANSLATABLE BUT LINKED TO TRANSLATED ' + + 'SECTION TITLE.'], + refs=['label-bridged-target-section']) + @with_intl_app(buildername='text', warning=warnfile) def test_i18n_glossary_terms_inconsistency(app): -- cgit v1.2.1 From e794c3cfd7ce600c288c110d639f6e8966364c38 Mon Sep 17 00:00:00 2001 From: Erik Bernoth Date: Mon, 23 Sep 2013 13:26:09 +0200 Subject: Make sure people know that they can actually use other document classes now. --- sphinx/quickstart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index 73926f82..6c47a113 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -231,7 +231,7 @@ latex_elements = { # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, -# author, documentclass [howto/manual]). +# author, documentclass [howto, manual, or own class]). latex_documents = [ ('%(master_str)s', '%(project_fn)s.tex', u'%(project_doc_texescaped_str)s', u'%(author_texescaped_str)s', 'manual'), -- cgit v1.2.1 From 496e04d2968bcea4b9afb4f7833d039ce0e24be1 Mon Sep 17 00:00:00 2001 From: Erik Bernoth Date: Mon, 23 Sep 2013 13:54:18 +0200 Subject: Note in the documentation, that prepending "sphinx" is not necessary anymore. --- doc/config.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/config.rst b/doc/config.rst index 24334f36..5f938ea6 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -999,11 +999,17 @@ These options influence LaTeX output. "sphinx" package in order to define Sphinx' custom LaTeX commands. "howto" documents will not get appendices. Also, howtos will have a simpler title page. + * *toctree_only*: Must be ``True`` or ``False``. If ``True``, the *startdoc* document itself is not included in the output, only the documents referenced by it via TOC trees. With this option, you can put extra stuff in the master document that shows up in the HTML, but not the LaTeX output. + .. versionadded:: 1.2 + In the past including your own document class required you to prepend the + document class name with the string "sphinx". This is not necessary + anymore. + .. versionadded:: 0.3 The 6th item ``toctree_only``. Tuples with 5 items are still accepted. -- cgit v1.2.1 From d77152916b265d1739c33d6b59a89b04bb6ce923 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Mon, 23 Sep 2013 22:58:37 +0900 Subject: update CHANGES for removing 'sphinx' prefix from latex document class name --- CHANGES | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES b/CHANGES index 44a246bf..ee71a916 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,10 @@ Features added Incompatible changes -------------------- +* PR#154: Remove "sphinx" prefix from LaTeX class name except 'sphinxmanual' + and 'sphinxhowto'. Now you can use your custom document class without + 'sphinx' prefix. Thanks to Erik B. + Bugs fixed ---------- -- cgit v1.2.1