Skip to content

Conversation

@hukkin
Copy link
Contributor

@hukkin hukkin commented Feb 25, 2021

Context: read the thread here hukkin/mdformat#132 (comment)

@codecov
Copy link

codecov bot commented Feb 25, 2021

Codecov Report

Merging #129 (a6d5c60) into master (11eb374) will decrease coverage by 0.22%.
The diff coverage is 91.30%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #129 +/- ## ========================================== - Coverage 96.42% 96.19% -0.23%  ========================================== Files 71 72 +1 Lines 2966 3104 +138 ========================================== + Hits 2860 2986 +126  - Misses 106 118 +12 
Flag Coverage Δ
pytests 96.19% <91.30%> (-0.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
markdown_it/utils.py 94.11% <75.00%> (-2.55%) ⬇️
markdown_it/tree.py 91.66% <91.66%> (ø)
markdown_it/token.py 91.95% <100.00%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11eb374...c96b2cb. Read the comment docs.

@chrisjsewell
Copy link
Member

Thanks firstly can you move this to a separate file: tree.py and also note in the module that this is not part of upstream markdown-it
Then also add a deprecation warning inside nest_tokens

@hukkin
Copy link
Contributor Author

hukkin commented Feb 25, 2021

@chrisjsewell 👍 done

@chrisjsewell
Copy link
Member

thanks, next can you add docstrings for all the methods and were we going to have is_nested and is_root properties?

@hukkin
Copy link
Contributor Author

hukkin commented Feb 25, 2021

thanks, next can you add docstrings for all the methods

Sure thing.

and were we going to have is_nested and is_root properties?

What do you think? I realized I don't have much need for these.

is_root basically equals not self.parent and that can be useful when traversing towards root and checking if you're already there. But in that context not self.parent feels more intuitive, because if you're not there yet, what you do next is self.parent.parent...

is_nested I never need in mdformat. That would be equal to bool(self.nester_tokens) which isn't overly onerous to do. And if the use case for is_nested is checking before accesing self.nester_tokens then bool(self.nester_tokens) could be more intuitive?

So basically just didn't add these because they weren't useful to me, but have no problem with adding them.

@chrisjsewell
Copy link
Member

yeh I think at least add the is_nested

@hukkin
Copy link
Contributor Author

hukkin commented Feb 25, 2021

We could enforce __init__ privateness (in favor of from_tokens) by something like adding a private mandatory kwarg:

def __init__(self, __internal_call=False): if not __internal_call: raise Exception("this is private API")

just an idea, not sure if a good one 😄

@chrisjsewell
Copy link
Member

just an idea, not sure if a good one

yeh not necessarily a bad idea lol, but probably overkill

@hukkin
Copy link
Contributor Author

hukkin commented Feb 25, 2021

Added docstrings and is_nested. Didn't add docstrings for the @propertyies that are just a passthrough from a Token. Do you think we need? There is a comment that kind of explains them as a whole.

@chrisjsewell
Copy link
Member

dn't add docstrings for the @propertyies that are just a passthrough from a Token. Do you think we need?

I would say yes (basically copied from the comments in Token), because they are helpful when e.g. working in editors like VS Code where you get the description when you hover over them

@hukkin
Copy link
Contributor Author

hukkin commented Feb 25, 2021

Yep, makes sense. Copied those from Token class.

@chrisjsewell
Copy link
Member

lastly, can you add a few extra bits to the test module, to increase the test coverage

@hukkin
Copy link
Contributor Author

hukkin commented Feb 25, 2021

Added. Tell me if you think there's something else in particular that you want tested.

@chrisjsewell
Copy link
Member

nah thats great cheers

@chrisjsewell chrisjsewell changed the title Add SyntaxTreeNode ✨ NEW: Add SyntaxTreeNode Feb 25, 2021
@chrisjsewell chrisjsewell merged commit 888636c into executablebooks:master Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants