Skip to content
This repository has been archived by the owner on Jan 3, 2018. It is now read-only.

DocParser should be changed to Parser in tools/check.py #299

Closed
naupaka opened this issue Apr 19, 2016 · 7 comments
Closed

DocParser should be changed to Parser in tools/check.py #299

naupaka opened this issue Apr 19, 2016 · 7 comments

Comments

@naupaka
Copy link
Member

naupaka commented Apr 19, 2016

On line 87 of tools/check.py,
parser = CommonMark.DocParser() should be changed to parser = CommonMark.Parser() to reflect the change in versions of CommonMark > 0.6.0.

See readthedocs/commonmark.py@e5e32bb

I'd submit this as a PR but I am not sure on the SWC policy on library versions and breaking old things to ensure compatibility with newest versions.

@justbennet
Copy link

On the off-chance that a simple change of the parse function would make things more better, I tried

$ git diff check.py
diff --git a/tools/check.py b/tools/check.py
index 0cbacc0..c72e713 100755
--- a/tools/check.py
+++ b/tools/check.py
@@ -84,7 +84,10 @@ class MarkdownValidator(object):
         self._callout_counts = collections.Counter()

     def _parse_markdown(self, markdown):
-        parser = CommonMark.DocParser()
+        if hasattr(CommonMark, 'DocParser'):
+            parser = CommonMark.DocParser()
+        else:
+            parser = CommonMark.Parser()
         ast = parser.parse(markdown)
         return ast

but no such luck. That throws the following error.

Traceback (most recent call last):
  File "tools/check.py", line 848, in <module>
    main(parsed_args)
  File "tools/check.py", line 833, in main
    res = validate_single(fn, template=template)
  File "tools/check.py", line 713, in validate_single
    validate_file = validator(filepath)
  File "tools/check.py", line 81, in __init__
    self.ast = vh.CommonMarkHelper(ast)
  File "/Users/bennet/carpenterbennet/r-novice-gapminder/tools/validation_helpers.py", line 59, in __init__
    self.children = self.data.children
AttributeError: Node instance has no attribute 'children'

I hope that's helpful to someone....

@abought
Copy link
Contributor

abought commented Apr 20, 2016

The recent releases of CommonMark have made a variety of internal code structure changes that broke compatibility. Good to see that project active after long dormancy, but admittedly we were taking the stability for granted.

A very short term fix would be to pin to the 0.5.4 version in requirements.txt:
CommonMark==0.5.4

(or manually downgrade using pip install CommonMark==0.5.4)

Longer term there are plans to change over to a different parser when the lessons do. Will this be a blocker for your work (if the proposed fix doesn't suffice)? I'm apparently absolute rubbish at predicting my schedule, but could dig further if it meant getting a lesson moving again.

@justbennet
Copy link

I can't speak for @naupaka, but that works for me. I manually downgraded, and it's now working.

@naupaka
Copy link
Member Author

naupaka commented Apr 20, 2016

Yup no problem for me either in the short term. I'm still using 0.5.4 anyway. I'll try and remember not to upgrade.

@gvwilson
Copy link
Contributor

gvwilson commented Apr 20, 2016 via email

@justbennet
Copy link

This was found in #291 as well. If it is resolved, both issues can be closed.

@gvwilson
Copy link
Contributor

We've rewritten tools/check.py completely.

Fil added a commit to Fil/D3-visualising-data that referenced this issue Jun 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants