I wanted the opposite of what the between function offered. So I modified between to accept an optional exclude flag that excludes lines that lie between lines that match the regex. The behavior is unchanged if this flag is not set to True. I'm not particularly sure how I am supposed to post a patch on here so I will just paste it into this message. Let me know if there is anything you need or any questions.
Thanks, Matt ps. I have a bitbucket patch queue here: http://bitbucket.org/mfperzel/sphinx-additions # HG changeset patch -- Bitbucket.org # Project sphinx-additions # URL http://bitbucket.org/mfperzel/sphinx-additions/overview # User m...@kubuntu # Date 1276048301 25200 # Node ID 6643ddb501bb028555365a397dfd2dbc47e55ae8 # Parent 73e7599fa26679872903052752f1cdb9ac8c0fd6 Modified sphinx.ext.autodoc.between() to have a flag to optionally exclude matches instead of including --- a/series +++ b/series @@ -1,1 +1,2 @@ +between_exclude # Placed by Bitbucket --- /dev/null +++ b/between_exclude @@ -0,0 +1,48 @@ +# HG changeset patch +# Parent 04464ddd8808c655110c8203a7cbd712df54ddbc + +diff -r 04464ddd8808 sphinx/ext/autodoc.py +--- a/sphinx/ext/autodoc.py Sat Jun 05 18:49:39 2010 +0200 ++++ b/sphinx/ext/autodoc.py Tue Jun 08 18:49:00 2010 -0700 +@@ -164,9 +164,9 @@ + lines.append('') + return process + +-def between(marker, what=None, keepempty=False): ++def between(marker, what=None, keepempty=False, exclude=False): + """ +- Return a listener that only keeps lines between lines that match the ++ Return a listener that either keeps, or if *exclude* is True excludes, lines between lines that match the + *marker* regular expression. If no line matches, the resulting docstring + would be empty, so no change will be made unless *keepempty* is true. + +@@ -178,7 +178,7 @@ + if what and what_ not in what: + return + deleted = 0 +- delete = True ++ delete = not exclude + orig_lines = lines[:] + for i, line in enumerate(orig_lines): + if delete: +diff -r 04464ddd8808 tests/test_autodoc.py +--- a/tests/test_autodoc.py Sat Jun 05 18:49:39 2010 +0200 ++++ b/tests/test_autodoc.py Tue Jun 08 18:49:00 2010 -0700 +@@ -282,6 +282,17 @@ + assert process('function', 'f', f) == ['second line', ''] + app.disconnect(lid) + ++ lid = app.connect('autodoc-process-docstring', between('---', ['function'], exclude=True)) ++ def f(): ++ """ ++ first line ++ --- ++ second line ++ --- ++ third line ++ """ ++ assert process('function', 'f', f) == ['first line', 'third line', ''] ++ app.disconnect(lid) + + def test_new_documenter(): + class MyDocumenter(ModuleLevelDocumenter): -- 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.
