Skip to content
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

error processing files on windows NT system #34

Open
ndarmage opened this issue Apr 8, 2021 · 1 comment
Open

error processing files on windows NT system #34

ndarmage opened this issue Apr 8, 2021 · 1 comment

Comments

@ndarmage
Copy link

ndarmage commented Apr 8, 2021

Hello,

when using sphinx-fortran on windows systems, I noticed that the function get_src in module fortran_autodoc.py was wrongly processing filenames with full path stored in block['from']. On win system, a letter is generally used to identify the storage drive, having a column ':' after this letter. The column is used to get the parent block, as in numpy.f2py.crackfortran.py docstring:

B['from'] --- string showing the 'parents' of the current block

This prevents correct execution of sphinx-fortran on win10 for instance.

I suggest the following new version of the function that fixed the issue in my case :

    def get_src(self, block):
        """Get the source lines of the file including this block"""
        srcfile = block['from']
        if os.name != 'nt' or not os.path.isfile(block['from']):
            srcfile = block['from'].split(':')[0]
        return self.src[srcfile]

Thanks for your kind attention.
Regards,
P.I.: I cannot use a pull request.

@ndarmage
Copy link
Author

ndarmage commented Apr 9, 2021

Other modification to get the expected behavior on win OS, use the following in function:

    def filter_by_srcfile(self, sfile, mode=None, objtype=None, **kwargs):
...
        for b in self.crack:
            if objtype and objtype != 'all' and b['block'] not in objtype:
                continue
            bfile = b['from']  # new line
            if os.name != 'nt' or not os.path.isfile(bfile):  # new line
                bfile = b['from'].split(':')[0]  # remove module name  / new line
            if mode != 'strict':
                bfile = os.path.basename(bfile)
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant