It seems like the cost of the change is too high. We shouldn't have to
change the syntax to allow some convenience feature.
-1 on the change.
David Goodger
On Fri, Jul 1, 2011 at 09:03, Guenter Milde <milde@...> wrote:
> On 2011-07-01, David Goodger wrote:
>> On Thu, Jun 30, 2011 at 18:16, Guenter Milde <milde@...> wrote:
>>> On 2011-06-30, Guenter Milde wrote:
>>>> On 2011-06-30, David Goodger wrote:
>
>>>>> "name" is the standard term in Docutils/reStructuredText. See the
>>>>> docs, the DTD, and the code.
>>>>> Let's use "name".
>
>>> Comitted.
>
>>> Should the Admonitions support "name" and "class" options, too?
>
>> +0
>
> It turns out to be somewhat more complicated than I first thought: for
> backwards compatibility (and brevity of the source) we must support
> content starting at the same line even with a non-empty option_spec.
>
> With the patches below, the following examples work:
>
> .. Attention:: Directives at large.
>
> .. Tip:: 15% if the
> service is good.
>
> .. Caution::
> :name: mycaution
>
> Don't take any wooden nickels.
>
> .. DANGER:: Mad scientist at work!
> :name: mydanger
>
> .. note:: This is a note admonition.
> This is the second line of the first paragraph.
>
> - The note contains all indented body elements
> following.
> - It includes this bullet list.
>
> .. admonition:: Custom
> :name: mycustom
>
> This is a generic amonition.
>
> I can link to mydanger_, mycaution_ and mycustom_.
>
>
> However, the directive syntax became more permissive, so that e.g. ::
>
> .. compound:: first paragraph
>
> second paragraph
>
> or ::
>
> .. parsed-literal:: content
>
> are valid and the following tests fail:
>
> FAIL: test_parsers/test_rst/test_directives/test_compound.py:
> totest['compound'][2]; test_parser (DocutilsTestSupport.ParserTestCase)
>
> FAIL: test_parsers/test_rst/test_directives/test_parsed_literals.py:
> totest['parsed_literals'][2]; test_parser
> (DocutilsTestSupport.ParserTestCase)
>
>
> Is it OK to update the tests and documentation and, commit the patches?
>
> Günter
>
> --- states.py (Revision 7055)
> +++ states.py (Arbeitskopie)
> @@ -2111,8 +2111,8 @@
> if indented and (directive.required_arguments
> or directive.optional_arguments
> or option_spec):
> - for i in range(len(indented)):
> - if not indented[i].strip():
> + for i, line in enumerate(indented):
> + if not line.strip():
> break
> else:
> i += 1
> @@ -2123,18 +2123,19 @@
> content = indented
> content_offset = line_offset
> arg_block = []
> - while content and not content[0].strip():
> - content.trim_start()
> - content_offset += 1
> if option_spec:
> options, arg_block = self.parse_directive_options(
> option_presets, option_spec, arg_block)
> - if arg_block and not (directive.required_arguments
> - or directive.optional_arguments):
> - raise MarkupError('no arguments permitted; blank line '
> - 'required before content block')
> else:
> options = {}
> + if arg_block and not (directive.required_arguments
> + or directive.optional_arguments):
> + content = arg_block + indented[i:]
> + content_offset = line_offset
> + arg_block = []
> + while content and not content[0].strip():
> + content.trim_start()
> + content_offset += 1
> if directive.required_arguments or directive.optional_arguments:
> arguments = self.parse_directive_arguments(
> directive, arg_block)
>
>
> --- admonitions.py (Revision 7055)
> +++ admonitions.py (Arbeitskopie)
> @@ -16,10 +16,9 @@
>
> class BaseAdmonition(Directive):
>
> - required_arguments = 0
> - optional_arguments = 0
> final_argument_whitespace = True
> - option_spec = {}
> + option_spec = {'class': directives.class_option,
> + 'name': directives.unchanged}
> has_content = True
>
> node_class = None
> @@ -29,6 +28,7 @@
> self.assert_has_content()
> text = '\n'.join(self.content)
> admonition_node = self.node_class(text)
> + self.add_name(admonition_node)
> if self.arguments:
> title_text = self.arguments[0]
> textnodes, messages = self.state.inline_text(title_text,
> @@ -48,7 +48,6 @@
> class Admonition(BaseAdmonition):
>
> required_arguments = 1
> - option_spec = {'class': directives.class_option}
> node_class = nodes.admonition
>
>
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> Docutils-develop mailing list
> Docutils-develop@...
> https://lists.sourceforge.net/lists/listinfo/docutils-develop
>
> Please use "Reply All" to reply to the list.
>
|