New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addressing problems raised in sphinx_issues #10104 #10379
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,5 @@ | ||||||
"""The MessageCatalogBuilder class.""" | ||||||
|
||||||
import os | ||||||
from codecs import open | ||||||
from collections import OrderedDict, defaultdict | ||||||
from datetime import datetime, timedelta, tzinfo | ||||||
|
@@ -32,7 +32,7 @@ class Message: | |||||
"""An entry of translatable message.""" | ||||||
def __init__(self, text: str, locations: List[Tuple[str, int]], uuids: List[str]): | ||||||
self.text = text | ||||||
self.locations = locations | ||||||
self.locations = list(set(locations)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd use
Suggested change
|
||||||
self.uuids = uuids | ||||||
|
||||||
|
||||||
|
@@ -57,7 +57,7 @@ def add(self, msg: str, origin: Union[Element, "MsgOrigin"]) -> None: | |||||
|
||||||
def __iter__(self) -> Generator[Message, None, None]: | ||||||
for message in self.messages: | ||||||
positions = [(source, line) for source, line, uuid in self.metadata[message]] | ||||||
positions = [(os.path.relpath(source, start=os.getcwd()), line) for source, line, uuid in self.metadata[message]] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Understandable change. But this should be moved to the outside of this class because this class does not have appropriate directory information. I think what directory you want is the base directory of the document (a.k.a srcdir). But it seems you're using BTW, please use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed the issue #10104 after the code reviews from Adam Turner and Takeshi Komiya:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Modifying global state like this is a bad idea, please could you refactor? A There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, adding a class variable is not a good idea. |
||||||
uuids = [uuid for source, line, uuid in self.metadata[message]] | ||||||
yield Message(message, positions, uuids) | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep a blank line here