Added Relation property support and Link to pages in rich text support #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If there is a link to a page in a relation property or a link in a rich text, the relation will be picked up by the graph.
To get the relation from a link in a rich text, I remove the leading
/
of the href to get the page UID, then I try to get the page from the api. If there is an exception, I assume the href was not a link to a notion page and move on.I had to implement a singleton that logs the relations created to avoid infinite loops.
All parsers that need to log the relation will need to get the id of the parent that calls the parser. It is required by the relation logger.
I'm not sure the API call to retrieve the page is necessary, we can probably just call BlockParser after we add the relation to the logger. I'll try it later and push the improvement.
Another area of improvement is the spacing of the nodes that are related. The edges overlap other edges where it could be avoided.
I also took the liberty of changing the name of parser.py so that it doesn't override the parser module from stdlib as warned by Pylance.
I don't know python so there is certainly a lot of room for improvement, feel free to point out anything that you would like me to fix or clarify.