]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Omit extra space in Sphinx auto-attribute comments
authorŁukasz Langa <lukasz@langa.pl>
Fri, 23 Mar 2018 15:56:55 +0000 (08:56 -0700)
committerŁukasz Langa <lukasz@langa.pl>
Fri, 23 Mar 2018 15:56:55 +0000 (08:56 -0700)
This feature of Sphinx is described in:
http://www.sphinx-doc.org/en/stable/ext/autodoc.html#directive-autoattribute

Fixes #68

README.md
black.py
tests/comments.py

index 014780bd1af7fad5a0c437b11504ca6435780b81..5d3b11850418d970ee389de2a875ee3cc0c9c823 100644 (file)
--- a/README.md
+++ b/README.md
@@ -324,6 +324,9 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
 
 * omit extra space in kwarg unpacking if it's the first argument (#46)
 
 
 * omit extra space in kwarg unpacking if it's the first argument (#46)
 
+* omit extra space in [Sphinx auto-attribute comments](http://www.sphinx-doc.org/en/stable/ext/autodoc.html#directive-autoattribute)
+  (#68)
+
 
 ### 18.3a3
 
 
 ### 18.3a3
 
index 7ca6bc6eaa47e91b1f55cf54832c4a950671c1b4..f03c4f16915309c817230916686ee0be90a8bb2d 100644 (file)
--- a/black.py
+++ b/black.py
@@ -1183,7 +1183,7 @@ def make_comment(content: str) -> str:
 
     if content[0] == '#':
         content = content[1:]
 
     if content[0] == '#':
         content = content[1:]
-    if content and content[0] not in {' ', '!', '#'}:
+    if content and content[0] not in ' !:#':
         content = ' ' + content
     return '#' + content
 
         content = ' ' + content
     return '#' + content
 
index 34b38fe8101cfd398fcb80845032d5242ef797ad..42e42f50671f553eeaa99f3cb7f018ad5ca2676b 100644 (file)
@@ -49,6 +49,26 @@ GLOBAL_STATE = {'a': a(1), 'b': a(2), 'c': a(3)}
 # This time two lines.
 
 
 # This time two lines.
 
 
+class Foo:
+    """Docstring for class Foo.  Example from Sphinx docs."""
+
+    #: Doc comment for class attribute Foo.bar.
+    #: It can have multiple lines.
+    bar = 1
+
+    flox = 1.5  #: Doc comment for Foo.flox. One line only.
+
+    baz = 2
+    """Docstring for class attribute Foo.baz."""
+
+    def __init__(self):
+        #: Doc comment for instance attribute qux.
+        self.qux = 3
+
+        self.spam = 4
+        """Docstring for instance attribute spam."""
+
+
 @fast(really=True)
 async def wat():
     async with X.open_async() as x:  # Some more comments
 @fast(really=True)
 async def wat():
     async with X.open_async() as x:  # Some more comments