From ea82247b76509cd82196b63e03b68faddd3c1032 Mon Sep 17 00:00:00 2001 From: "Micah D. Gale" Date: Mon, 22 Jul 2024 10:32:50 -0500 Subject: [PATCH 1/6] Replicated the error is #458 --- tests/inputs/test.imcnp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/inputs/test.imcnp b/tests/inputs/test.imcnp index fd0d4cbe..1718b45e 100644 --- a/tests/inputs/test.imcnp +++ b/tests/inputs/test.imcnp @@ -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 From d7c06ef7c9c73473bef7db011d8dfb207a004d29 Mon Sep 17 00:00:00 2001 From: "Micah D. Gale" Date: Mon, 22 Jul 2024 10:42:08 -0500 Subject: [PATCH 2/6] Moved only first c style comment for trailing comments. --- montepy/input_parser/syntax_node.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/montepy/input_parser/syntax_node.py b/montepy/input_parser/syntax_node.py index 437b065a..7be1f7e2 100644 --- a/montepy/input_parser/syntax_node.py +++ b/montepy/input_parser/syntax_node.py @@ -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 @@ -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 From 313a3c19e999c3e0d16ed458da7bf4bbf935cad9 Mon Sep 17 00:00:00 2001 From: "Micah D. Gale" Date: Mon, 22 Jul 2024 10:42:23 -0500 Subject: [PATCH 3/6] Updated trailing comments test to new paradigm. --- tests/test_syntax_parsing.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_syntax_parsing.py b/tests/test_syntax_parsing.py index 9bd42fe1..67e54f37 100644 --- a/tests/test_syntax_parsing.py +++ b/tests/test_syntax_parsing.py @@ -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) @@ -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()) @@ -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) @@ -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()) From ce579b687420c1dc10742a966d5180a00d177a72 Mon Sep 17 00:00:00 2001 From: "Micah D. Gale" Date: Mon, 22 Jul 2024 10:44:00 -0500 Subject: [PATCH 4/6] Added bug fix to changelog. --- doc/source/changelog.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index bcd8debb..9724c9e1 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -1,6 +1,13 @@ MontePy Changelog ================= +#Next Version# +------------- + +**Bug fixes** + +* Fixed bug with trailing dollar sign comments that moved them to a new line. (:issue:`458`). + 0.3.1 ---------------- From f6d8dbdff95653f278259addc5f41883dba3f233 Mon Sep 17 00:00:00 2001 From: "Micah D. Gale" Date: Mon, 22 Jul 2024 12:49:08 -0500 Subject: [PATCH 5/6] Fixed underlining error. --- doc/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index 9724c9e1..e8d7db30 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -2,7 +2,7 @@ MontePy Changelog ================= #Next Version# -------------- +-------------- **Bug fixes** From 66089ea372829ceda70569742d50d321141e4aff Mon Sep 17 00:00:00 2001 From: "Micah D. Gale" Date: Mon, 22 Jul 2024 15:46:03 -0500 Subject: [PATCH 6/6] Updating changelog to next version: 0.3.2 --- doc/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index e8d7db30..8f317767 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -1,7 +1,7 @@ MontePy Changelog ================= -#Next Version# +0.3.2 -------------- **Bug fixes**