pycco-docs / pycco

Literate-style documentation generator.
https://pycco-docs.github.io/pycco/
Other
842 stars 146 forks source link

pycco files/*.py -p #124

Open HananxR opened 10 months ago

HananxR commented 10 months ago

run: pycco files/*.py -p

result error:OSError: [Errno 22] Invalid argument: 'docs\\maths\\*.html'

The detailed operation logs are as follows:

(py38) E:\MyGit\Pycco>dir
 Volume in drive E is 软件
 Volume Serial Number is CEA1-974F

 Directory of E:\MyGit\Pycco

2023/09/01  16:05    <DIR>          .
2023/09/01  16:03    <DIR>          ..
2023/09/01  16:09    <DIR>          docs
2023/09/01  16:11    <DIR>          maths
               0 File(s)              0 bytes
               4 Dir(s)  10,671,063,040 bytes free

(py38) E:\MyGit\Pycco>cd maths

(py38) E:\MyGit\Pycco\maths>pycco maths/*.py -p
Traceback (most recent call last):
  File "D:\software\Anaconda3\envs\py38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\software\Anaconda3\envs\py38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\software\Anaconda3\envs\py38\Scripts\pycco.exe\__main__.py", line 7, in <module>
  File "D:\software\Anaconda3\envs\py38\lib\site-packages\pycco\main.py", line 629, in main
    process(args.sources, outdir=outdir, preserve_paths=args.paths,
  File "D:\software\Anaconda3\envs\py38\lib\site-packages\pycco\main.py", line 533, in process
    next_file()
  File "D:\software\Anaconda3\envs\py38\lib\site-packages\pycco\main.py", line 517, in next_file
    with open(dest, "wb") as f:
OSError: [Errno 22] Invalid argument: 'docs\\maths\\*.html'

But I run pycco maths/add.py,it's ok. so What is the reason for this?

maths structure is as follows:

(py38) E:\MyGit\Pycco\maths>dir
 Volume in drive E is 软件
 Volume Serial Number is CEA1-974F

 Directory of E:\MyGit\Pycco\maths

2023/09/01  16:11    <DIR>          .
2023/09/01  16:05    <DIR>          ..
2023/09/01  16:18               778 add.py
2023/09/01  16:17               770 add.py.bak
2022/03/17  20:55               272 divide.py
2023/09/01  16:06    <DIR>          docs
2022/03/17  20:55               291 multiply.py
2022/03/17  20:55               278 subtract.py
2022/03/17  20:55                 0 __init__.py
2023/09/01  16:03    <DIR>          __pycache__
               6 File(s)          2,389 bytes
               4 Dir(s)  10,671,063,040 bytes free

(py38) E:\MyGit\Pycco\maths>

python version:3.8.5 operating system:win11

subsetpark commented 10 months ago

It looks like you’re using Unix glob syntax with Windows? I don’t have windows, so I’m not sure if that’s expected to work.

jshipley commented 5 months ago

Windows does not do shell expansion in the same way that sh does, it expects the program to do the shell expansion.

The best way to handle this input would be to use glob (either from pathlib.Path or glob) to expand the sources before using them.

As a workaround (in powershell), you could run this to expand the glob before passing it to pycco.

pycco -p (maths/*.py | Resolve-Path -Relative)

Or if you wanted to do something like myproject/*/.py, you could do it like this:

pycco -p (Get-ChildItem -Recurse -Path myproject -File -Filter *.py | Resolve-Path -Relative)