Skip to content
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

Release 0.3.2 #460

Merged
merged 7 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
MontePy Changelog
=================

0.3.2
--------------

**Bug fixes**

* Fixed bug with trailing dollar sign comments that moved them to a new line. (:issue:`458`).

0.3.1
----------------

Expand Down
6 changes: 3 additions & 3 deletions montepy/input_parser/syntax_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def comments(self):

def get_trailing_comment(self):
"""
Get the trailing comments if any.
Get the trailing ``c`` style comments if any.

:returns: The trailing comments of this tree.
:rtype: list
Expand Down Expand Up @@ -427,13 +427,13 @@ def comments(self):

def _get_first_comment(self):
"""
Get the first index that is a comment.
Get the first index that is a ``c`` style comment.

:returns: the index of the first comment, if there is no comment then None.
:rtype: int, None
"""
for i, item in enumerate(self.nodes):
if isinstance(item, CommentNode):
if isinstance(item, CommentNode) and not item.is_dollar:
return i
return None

Expand Down
2 changes: 1 addition & 1 deletion tests/inputs/test.imcnp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ C Iron
m2 26054.80c 5.85
26056.80c 91.75
26057.80c 2.12
26058.80c 0.28
26058.80c 0.28 $ trailing comment shouldn't move #458.
C water
C foo
m3 1001.80c 2
Expand Down
10 changes: 6 additions & 4 deletions tests/test_syntax_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def test_value_trailing_comments(self):
self.assertIsNone(value_node.get_trailing_comment())
value_node._delete_trailing_comment()
self.assertIsNone(value_node.get_trailing_comment())
padding = syntax_node.PaddingNode("$ hi", True)
padding = syntax_node.PaddingNode("c hi", True)
value_node.padding = padding
comment = value_node.get_trailing_comment()
self.assertEqual(len(comment), 1)
Expand Down Expand Up @@ -431,7 +431,7 @@ def test_syntax_trailing_comments(self):
test = copy.deepcopy(self.test_node)
test["bar2"].nodes["foo"] = syntax_node.ValueNode("1.23", float)
self.assertIsNone(test.get_trailing_comment())
test["bar2"]["foo"].padding = syntax_node.PaddingNode("$ hi", True)
test["bar2"]["foo"].padding = syntax_node.PaddingNode("c hi", True)
self.assertEqual(len(test.get_trailing_comment()), 1)
test._delete_trailing_comment()
self.assertIsNone(test.get_trailing_comment())
Expand Down Expand Up @@ -691,7 +691,7 @@ def test_list_trailing_comment(self):
list_node1 = syntax_node.ListNode("list")
for i in range(20):
list_node1.append(syntax_node.ValueNode("1.0", float))
padding = syntax_node.PaddingNode("$ hi", True)
padding = syntax_node.PaddingNode("c hi", True)
list_node1[-1].padding = padding
comments = list(list_node1.get_trailing_comment())
self.assertEqual(len(comments), 1)
Expand Down Expand Up @@ -1481,7 +1481,9 @@ def test_parameter_trailing_comments(self):
padding = syntax_node.PaddingNode("$ hi", True)
param["vol"]["data"][0].padding = padding
comment = param.get_trailing_comment()
self.assertEqual(len(comment), 1)
self.assertIsNone(comment)
padding.append(syntax_node.CommentNode("c hi"), True)
comment = param.get_trailing_comment()
self.assertEqual(comment[0].contents, "hi")
param._delete_trailing_comment()
self.assertIsNone(param.get_trailing_comment())
Expand Down