sphinx-contrib / matlabdomain

A Sphinx extension for documenting Matlab code
http://sphinxcontrib-matlabdomain.readthedocs.io/
Other
70 stars 45 forks source link

CRLF in function signature causes: "Test data can not be parsed: TypeError: Expected a whitespace after function keyword." #33

Closed joeced closed 6 years ago

joeced commented 10 years ago

Originally reported by: Lukas Drude (Bitbucket: lukas_drude, GitHub: Unknown)


I am working with Kubuntu 14.04 and hg revision: 1557:04a335dec66c

I installed everything as follows:

#!bash
sudo pip2 install sphinx
hg clone https://bitbucket.org/bwanamarko/sphinxcontrib-matlabdomain .
cd matlabdomain/
sudo python setup.py install
cd tests

When I run

#!bash

python2 test_mat_types.py

, I get:

#!python
test_ellipsis_after_equals
__main__

    test function with ellipsis after equals

        <test-mode>
[MATLAB-domain] matlabify test_data from
        /home/lukas/hgSphinx/matlabdomain/tests/test_data.
        <test-mode>
[MATLAB-domain] matlabify test_data.test_submodule from
        /home/lukas/hgSphinx/matlabdomain/tests/test_data/test_submodule.
        <test-mode>
[MATLAB-domain] attr test_submodule imported from mod <MatModule: "test_data">.
        <test-mode>
[MATLAB-domain] WARNING Attribute "f_no_args" was not found in <MatModule: "test_submodule">.
Traceback (most recent call last):
  File "test_mat_types.py", line 121, in <module>
    f2 = test_no_args()
  File "test_mat_types.py", line 35, in test_no_args
    ok_(isinstance(f, doc.MatFunction))
  File "/usr/lib/python2.7/dist-packages/nose/tools/trivial.py", line 22, in ok_
    raise AssertionError(msg)
AssertionError: None

When I do:

#!bash

cd test_docs/
make html

, I get:

#!python
phinx-build -b html -d _build/doctrees   . _build/html
Running Sphinx v1.2.3
loading pickled environment... not yet created
building [html]: targets for 1 source files that are out of date
updating environment: 1 added, 0 changed, 0 removed
reading sources... [100%] index                                                                                                        
Exception occurred:
  File "/usr/local/lib/python2.7/dist-packages/sphinxcontrib_matlabdomain-0.2.5dev_20141010-py2.7.egg/sphinxcontrib/mat_types.py", line 421, in __init__
    raise TypeError('Expected a whitespace after function keyword.')
TypeError: Expected a whitespace after function keyword.
The full traceback has been saved in /tmp/sphinx-err-ssiAS4.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
make: *** [html] Fehler 1

This bug may be related to Issue #26.


joeced commented 6 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


fixes #28 CRLF in function signature

joeced commented 9 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


fixes #28 CRLF in function signature

joeced commented 10 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


Issue #27 was marked as a duplicate of this issue.

joeced commented 10 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


issue #27 is a duplicate of this issue

joeced commented 10 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


joeced commented 10 years ago

Original comment by Lukas Drude (Bitbucket: lukas_drude, GitHub: Unknown):


You are correct. I did the following:

#!bash
sudo apt-get install tofrodos # Installs a converter to remove CRLF
cd sphinxcontrib-matlabdomain/matlabdomain/tests/test_data/
find ./ -iname "*.m" -exec fromdos {} \;
cd ../test_docs/
make html

Now, the examples are correctly translated.

joeced commented 10 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


I too had this problem @lukas_drude when I went to test it on a linux box after working on a windows machine. I am very sorry. Somehow, the newline characters were replaced by CRLF. To solve this problem, run dos2unix tests\test_data\*.m for all files in test data or on a Macintosh you can use for f in *.m do tr -d '\r' < $f > $f done. I will try to fix the newlines in the test data and push them to the repo when I get a chance. Send a pull request if you want.