Skip to content

Commit

Permalink
Add a warning
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed May 31, 2022
1 parent bca9e48 commit 34a8296
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sphinx/builders/gettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ def add(self, msg: str, origin: Union[Element, "MsgOrigin"]) -> None:
if msg not in self.metadata: # faster lookup in hash
self.messages.append(msg)
self.metadata[msg] = []
self.metadata[msg].append((origin.source, origin.line, origin.uid)) # type: ignore
line = origin.line
if line is None:
logger.warning(f"Node {origin!r} has no line number, using '-1'.")
line = -1
self.metadata[msg].append((origin.source, line, origin.uid)) # type: ignore

def __iter__(self) -> Generator[Message, None, None]:
for message in self.messages:
positions = sorted(set((source, line or -1) for source, line, uuid
positions = sorted(set((source, line) for source, line, uuid
in self.metadata[message]))
uuids = [uuid for source, line, uuid in self.metadata[message]]
yield Message(message, positions, uuids)
Expand Down

0 comments on commit 34a8296

Please sign in to comment.