diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-07-24 17:49:45 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-07-24 17:49:45 +0300 |
commit | 327c1872841bc6a98aa766fc3d7ee921e6d3b658 (patch) | |
tree | d3424f7aadc4a3118eb7fb72e245b4fbe8391e58 /sphinx/pycode | |
parent | dc63eaf196d37c70410d37c3d28297fb513f7f6d (diff) | |
parent | 5b096c42ff3a907fa7bcce3fa620209da16d40bd (diff) |
Merge branch '3.x'
Diffstat (limited to 'sphinx/pycode')
-rw-r--r-- | sphinx/pycode/__init__.py | 3 | ||||
-rw-r--r-- | sphinx/pycode/parser.py | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py index 295963ca3..943c77244 100644 --- a/sphinx/pycode/__init__.py +++ b/sphinx/pycode/__init__.py @@ -10,6 +10,7 @@ import re import tokenize +from collections import OrderedDict from importlib import import_module from inspect import Signature from io import StringIO @@ -145,7 +146,7 @@ class ModuleAnalyzer: parser = Parser(self.code) parser.parse() - self.attr_docs = {} + self.attr_docs = OrderedDict() for (scope, comment) in parser.comments.items(): if comment: self.attr_docs[scope] = comment.splitlines() + [''] diff --git a/sphinx/pycode/parser.py b/sphinx/pycode/parser.py index a6f9b1643..a417b5a1b 100644 --- a/sphinx/pycode/parser.py +++ b/sphinx/pycode/parser.py @@ -12,6 +12,7 @@ import itertools import re import sys import tokenize +from collections import OrderedDict from inspect import Signature from token import NAME, NEWLINE, INDENT, DEDENT, NUMBER, OP, STRING from tokenize import COMMENT, NL @@ -231,7 +232,7 @@ class VariableCommentPicker(ast.NodeVisitor): self.context = [] # type: List[str] self.current_classes = [] # type: List[str] self.current_function = None # type: ast.FunctionDef - self.comments = {} # type: Dict[Tuple[str, str], str] + self.comments = OrderedDict() # type: Dict[Tuple[str, str], str] self.annotations = {} # type: Dict[Tuple[str, str], str] self.previous = None # type: ast.AST self.deforders = {} # type: Dict[str, int] |