summaryrefslogtreecommitdiff
path: root/sphinx/pycode/parser.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-07-19 16:00:52 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-07-19 16:00:52 +0900
commitb6bf2b88cef6c2b1517d7948c61ca86abb20fd77 (patch)
treef06bf57522ae137b736e344e1db01b461a0f3c79 /sphinx/pycode/parser.py
parent68c732e97c67a092c32ca2bfad30b96b4ffc0f0a (diff)
downloadsphinx-git-b6bf2b88cef6c2b1517d7948c61ca86abb20fd77.tar.gz
refactor: pycode: Use OrderedDict to store variable comments
It is worthy to keep the order of analyzer.attr_docs to generate document in reproducible. So this uses OrderedDict explicitly to do that. It also helps python3.5 environment.
Diffstat (limited to 'sphinx/pycode/parser.py')
-rw-r--r--sphinx/pycode/parser.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/sphinx/pycode/parser.py b/sphinx/pycode/parser.py
index d2e8fb976..be9bfc96d 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
@@ -228,7 +229,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]