pycco-docs / pycco

Literate-style documentation generator.

Home Page:https://pycco-docs.github.io/pycco/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pycco is unable to determine syntax for a Python3-formatted file without an appropriate extension

zachriggle opened this issue · comments

When running pycco file, it works well when the file is named foo.py, but does not work for foo despite having a shebang.

Example Script

Create this file as example. Note that if it is named example.py, everything works as expected.

#!/usr/bin/env python3
import os

class CommandLineFlag(object):
    '''Holds information about a command-line argument'''

Pycco Output

$ pycco example
Traceback (most recent call last):
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 397, in get_language
    raise ValueError()
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zachriggle/Library/Python/3.8/bin/pycco", line 10, in <module>
    sys.exit(main())
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 629, in main
    process(args.sources, outdir=outdir, preserve_paths=args.paths,
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 533, in process
    next_file()
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 518, in next_file
    f.write(generate_documentation(s, preserve_paths=preserve_paths,
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 80, in generate_documentation
    return _generate_documentation(source, code, outdir, preserve_paths, language)
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 87, in _generate_documentation
    language = get_language(file_path, code, language_name=language)
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 402, in get_language
    raise ValueError("Can't figure out the language!")
ValueError: Can't figure out the language!

It looks like this is an underlying issue to the pygments library:

$ head -1 bin/code-audit-asserts
#!/usr/bin/env zsh

$ pygmentize bin/code-audit-asserts
Error: no lexer for filename 'bin/code-audit-asserts' found