|
From: <mi...@us...> - 2016-07-27 10:38:36
|
Revision: 7955
http://sourceforge.net/p/docutils/code/7955
Author: milde
Date: 2016-07-27 10:38:34 +0000 (Wed, 27 Jul 2016)
Log Message:
-----------
"use_source_date_epoch" config setting.
Use SOURCE_DATE_EPOCH timestamp only if "use_source_date_epoch" config setting
is enabled.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/parsers/rst/__init__.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
Added Paths:
-----------
trunk/docutils/test/test_parsers/test_rst/test_directives/test_date_source_date_epoch.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2016-07-26 23:17:34 UTC (rev 7954)
+++ trunk/docutils/HISTORY.txt 2016-07-27 10:38:34 UTC (rev 7955)
@@ -32,6 +32,7 @@
* docutils/parsers/rst/directives/misc.py
- Apply [ 132 ] Add SOURCE_DATE_EPOCH support to date directive.
+ Activate with the "use_source_date_epoch" config setting.
* docutils/parsers/rst/directives/tables.py
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2016-07-26 23:17:34 UTC (rev 7954)
+++ trunk/docutils/docs/user/config.txt 2016-07-27 10:38:34 UTC (rev 7955)
@@ -588,6 +588,32 @@
[restructuredtext parser]
-------------------------
+character_level_inline_markup
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Experimental setting to relax the `inline markup recognition rules`_
+requiring whitespace or punctuation around inline markup.
+
+Allows character level inline markup without escaped whithespace and is
+especially suited for langauges that do not use whitespace to separate words
+(e.g. Japanese, Chinese).
+
+.. WARNING:: Potentially dangerous; use with caution.
+
+ When changing this setting to "True", inline markup charactes in
+ URLs, names and formulas must be escaped to prevent recognition and
+ possible errors. Examples::
+
+ http://rST_for_all.html (hyperlinks to rST_ and for_)
+ x_2, inline_markup (hyperlinks to x_ and inline_)
+ 2*x (starts emphasised text)
+ a|b (starts a substitution reference)
+
+Default: disabled (False).
+Options: ``--character-level-inline-markup, --word-level-inline-markup``.
+
+New in Docutils 0.13.
+
file_insertion_enabled
~~~~~~~~~~~~~~~~~~~~~~
@@ -649,33 +675,6 @@
Default: "http://www.faqs.org/rfcs/". Option: ``--rfc-base-url``.
-character_level_inline_markup
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Experimental setting to relax the `inline markup recognition rules`_
-requiring whitespace or punctuation around inline markup.
-
-Allows character level inline markup without escaped whithespace and is
-especially suited for langauges that do not use whitespace to separate words
-(e.g. Japanese, Chinese).
-
-.. WARNING:: Potentially dangerous; use with caution.
-
- When changing this setting to "True", inline markup charactes in
- URLs, names and formulas must be escaped to prevent recognition and
- possible errors. Examples::
-
- http://rST_for_all.html (hyperlinks to rST_ and for_)
- x_2, inline_markup (hyperlinks to x_ and inline_)
- 2*x (starts emphasised text)
- a|b (starts a substitution reference)
-
-Default: disabled (False).
-Options: ``--character-level-inline-markup, --word-level-inline-markup``.
-
-New in Docutils 0.13.
-
-
smart_quotes
~~~~~~~~~~~~
@@ -745,6 +744,27 @@
__ `footnote_references [latex2e writer]`_
+use_source_date_epoch
+~~~~~~~~~~~~~~~~~~~~~
+
+Use timestamp from the `SOURCE_DATE_EPOCH`_ environment variable for the
+`date directive`_.
+
+With this setting and environment variable, Docutils-generated documentation
+can be part of `reproducible software builds`_
+
+Default: disabled (False).
+Options: ``--use-source-date-epoch``.
+
+New in Docutils 0.13.
+
+.. _SOURCE_DATE_EPOCH:
+ https://reproducible-builds.org/specs/source-date-epoch/
+.. _reproducible software builds:
+ https://reproducible-builds.org/
+.. _date directive: ../ref/rst/directives.html#date
+
+
[readers]
=========
Modified: trunk/docutils/docutils/parsers/rst/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/__init__.py 2016-07-26 23:17:34 UTC (rev 7954)
+++ trunk/docutils/docutils/parsers/rst/__init__.py 2016-07-27 10:38:34 UTC (rev 7955)
@@ -155,6 +155,10 @@
['--character-level-inline-markup'],
{'action': 'store_true', 'default': False,
'dest': 'character_level_inline_markup'}),
+ ('Use timestamp from SOURCE_DATE_EPOCH environment variable '
+ 'for the "date" directive.',
+ ['--use-source-date-epoch'],
+ {'action': 'store_true', 'validator': frontend.validate_boolean}),
))
config_section = 'restructuredtext parser'
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2016-07-26 23:17:34 UTC (rev 7954)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2016-07-27 10:38:34 UTC (rev 7955)
@@ -231,7 +231,7 @@
raise self.severe(u'Problems with "%s" directive URL "%s":\n%s.'
% (self.name, self.options['url'], ErrorString(error)))
raw_file = io.StringInput(source=raw_text, source_path=source,
- encoding=encoding,
+ encoding=encoding,
error_handler=e_handler)
try:
text = raw_file.read()
@@ -477,8 +477,12 @@
except UnicodeEncodeError:
raise self.warning(u'Cannot encode date format string '
u'with locale encoding "%s".' % locale_encoding)
- source_date_epoch = os.environ.get('SOURCE_DATE_EPOCH')
- if source_date_epoch:
+ if self.state.document.settings.use_source_date_epoch:
+ try:
+ source_date_epoch = os.environ['SOURCE_DATE_EPOCH']
+ except KeyError:
+ raise self.warning(u'setting "use_source_date_epoch" enabled '
+ u'but SOURCE_DATE_EPOCH environment variable not set.')
text = time.strftime(format_str,
time.gmtime(int(source_date_epoch)))
else:
Added: trunk/docutils/test/test_parsers/test_rst/test_directives/test_date_source_date_epoch.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_date_source_date_epoch.py (rev 0)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_date_source_date_epoch.py 2016-07-27 10:38:34 UTC (rev 7955)
@@ -0,0 +1,53 @@
+#! /usr/bin/env python
+
+# $Id$
+# Author: David Goodger <go...@py...>
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for the misc.py "date" directive.
+"""
+
+from __init__ import DocutilsTestSupport
+import time, os
+
+from docutils.utils.error_reporting import locale_encoding
+
+os.environ['SOURCE_DATE_EPOCH'] = '5000000'
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite(suite_settings={'use_source_date_epoch':True})
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['date'] = [
+["""\
+.. |date| date::
+
+Today's date is |date|.
+""",
+"""\
+<document source="test data">
+ <substitution_definition names="date">
+ 1970-02-27
+ <paragraph>
+ Today's date is \n\
+ <substitution_reference refname="date">
+ date
+ .
+"""],
+["""\
+.. |date| date:: %a, %d %b %Y %H:%M
+""",
+"""\
+<document source="test data">
+ <substitution_definition names="date">
+ Fri, 27 Feb 1970 20:53
+"""],
+]
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_directives/test_date_source_date_epoch.py
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|