-
Notifications
You must be signed in to change notification settings - Fork 3
Top Level Information copied down a level #7
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
Comments
I'm still not sure about how to fix the issue, but I took an hour or so to put together a test case showing the failure. If you add the following line to the top of import sys, io Then add the following class to the test examples: class TestMarkdown(unittest.TestCase):
def test_basic(self):
old_stdout = sys.stdout
new_stdout = io.StringIO()
sys.stdout = new_stdout
markdown_result = yamldoc.main(yaml_path = "test/yaml/basic.yaml", schema_path = "test/schema/basic.schema")
output = new_stdout.getvalue()
sys.stdout = old_stdout
proper_markdown = """# Configuration Parameters Reference\n\nAny information about this page goes here.\n\n| Key | Value | Type | Information |\n| :-: | :-: | :-: | :-- |\n| `meta` | `"Data"` | string | Here is some meta data. |\n| `fun` | `True` | bool | And here is some more split over a couple of<br />lines. |\n\n\n\n---\nGenerated by [yamldoc](https://github.com/chris1221/yaml.doc) v0.1.6 on 2023-06-06\n"""
self.assertTrue(output == proper_markdown)
def test_two_level(self):
old_stdout = sys.stdout
new_stdout = io.StringIO()
sys.stdout = new_stdout
markdown_result = yamldoc.main(yaml_path = "test/yaml/two_level.yaml", schema_path = "test/schema/two_level.schema")
output = new_stdout.getvalue()
sys
8000
.stdout = old_stdout
proper_markdown = """# Configuration Parameters Reference\n\nAny information about this page goes here.\n\n| Key | Value | Type | Information |\n| :-: | :-: | :-: | :-- |\n| `flat` | `"yes"` | string | This is a flat entry. |\n\n\n\n## `two`\n\n But this is a two level thing.\n\n### Member variables:\n\n| Key | Value | Type | Information |\n| :-: | :-: | :-: | :-- |\n| `entry` | `"hi"` | [\'string\', \'number\'] | These can have<br />documentation too. |\n\n\n\n---\nGenerated by [yamldoc](https://github.com/chris1221/yaml.doc) v0.1.6 on 2023-06-06\n"""
print("\n\nActual Output:\n\n", output)
print("\n\nExpected Output:\n\n", proper_markdown)
self.assertTrue(output == proper_markdown) I have the basic test passing with the expected Markdown. The two-level has the strange piece of information and the print statements in the test show it the current way and the expected way. If it's valuable, I can submit a PR at least for the test updates... the fix still isn't clear to me yet. Hope this is helpful! |
Thanks very much for using the package, Josh! Some parts of the code are (very) janky, I appreciate you taking a look and investigating the issue. I don't immediately know what is causing this issue but having the test case will be incredibly valuable, if it's not too much trouble would you mind submitting that as a PR against the |
Done! |
Hey @jdhaines, I think I figured it out. Would you mind seeing if the proposed solution in #9 works for you? I tried it on your simple case above and it looks correct to me, but I'm sure your actual file is larger so wanted to circle back and see if there are any other lingering bugs to fix yamldoc demo.yaml -s demo.schema gives the expected Markdown without
|
Key | Value | Type | Information |
---|---|---|---|
commit |
19393 |
string | commit comments |
commitDate |
2023-06-02 |
string | commitDate comments |
version |
3.3.2 |
string | version comments |
repositoryLink |
github |
string | repositoryLink comments |
Generated by yamldoc v0.1.6 on 2023-06-10
Hey, @Chris1221 this looks good to me. Thanks for pushing the fix so quickly! It seems obvious now that I see what you updated. |
fix: correctly flush metadata after top level entry and remove extra whitespace (fix #7)
Great! Happy to be of assistance and very much appreciate you finding the bug |
Hi, great library! I'm having a strange issue and I can't sort out where to fix it in the code. If you give me a hint I could potentially submit a PR.
With small input files:
creates the markdown:
Problem: The information for the top key (ChangeDetailscomments) is also put at the beginning of the information for the lower level key commit. I'm not sure why, and printing various outputs from the python code didn't seem to give me a clue.
I'm seeing the same issue in your two level text example. Thanks again for the cool library!
The text was updated successfully, but these errors were encountered: