tomtom-international / asciidoxy

AsciiDoxy generates API documentation from Doxygen XML output to AsciiDoc.
Apache License 2.0
31 stars 10 forks source link

Bug - Conversion does not work on Windows 10 #33

Closed r0ckarong closed 3 years ago

r0ckarong commented 3 years ago

I've set up the example project like described in the docs. However, when I run AsciiDoxy it complains about not being able to find the specified path.

When I run the exact Asciidoctor command that if fails with (including all the double backslashes) it seems to work OK and I get some output in the correct directory.

I already tried progressing with the examples and added some doxygen files but the problem remains the same.

File structure ``` C:. | packages.toml | +---build | +---fragments | +---intermediate | | | .asciidoxy.index.adoc | | | index.adoc | | | reference.adoc | | | | | \---images | \---output | .asciidoxy.index.html | index.html | \---my-package | contents.toml | +---images +---src | index.adoc | reference.adoc | \---xml | \---build +---fragments \---intermediate | .asciidoxy.group__iolm__dl__api__netiol__cfgflg.xml | group__iolm__dl__api__netiol__cfgflg.xml | \---images ```
Asciidoxy output ``` asciidoxy --base-dir .\src\ .\src\index.adoc ___ _ _ ____ 0.7.4 / | __________(_|_) __ \____ _ ____ __ / /| | / ___/ ___/ / / / / / __ \| |/_/ / / / / ___ |(__ ) /__/ / / /_/ / /_/ /> File "c:\python39\lib\site-packages\asciidoxy\cli.py", line 244, in main asciidoctor(destination_dir, out_file, out_adoc_file, args.multipage, args.backend, File "c:\python39\lib\site-packages\asciidoxy\cli.py", line 44, in asciidoctor subprocess.run([ File "c:\python39\lib\subprocess.py", line 528, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['asciidoctor -D C:\\mydata\\software\\asciidoxy-test\\build\\output -o C:\\mydata\\software\\asciidoxy-test\\build\\output\\index.html -b html5 -a imagesdir@=images C:\\mydata\\software\\asciidoxy-test\\build\\intermediate\\.asciidoxy.index.adoc ']' returned non-zero exit status 1. ```
python --version
Python 3.9.2
asciidoctor --version
Asciidoctor 2.0.12 [https://asciidoctor.org]
Runtime Environment (ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x64-mingw32]) 
(lc:CP850 fs:Windows-1252 in:UTF-8 ex:UTF-8)
r0ckarong commented 3 years ago

I'm suspecting a problem with how it tries to find the asciidoctor executable in Windows but the Path correctly contains the ruby bin directory and directly calling the asciidoctor command from the subprocess works fine.

r0ckarong commented 3 years ago

I realized now that it actually generates the intermediate files but fails to convert them to the final HTML on its own because of the bug.

RerrerBuub commented 3 years ago

To run AsciiDoxy on Windows and python 3.8.0 The following replacement of the function asciidoctor at cli.py can be used as workaround


def asciidoctor(destination_dir: Path, out_file: Path, processed_file: Path, multipage: bool,
                backend: str, extra_args: Sequence[str], image_dir: Path) -> None:

    args = [
        "asciidoctor",
        "-D", f"{destination_dir}", "-o", f"{out_file}", "-b" ,f"{backend}",
        "-a", f"imagesdir@={image_dir}",
        f"{processed_file}", 
    ]
    if multipage:
      args = args + ["-a","multipage",]
    args = args + extra_args

    subprocess.run(args,
                   shell=True,
                   check=True)
silvester747 commented 3 years ago

Thank you for the suggestion. It was a little more involved than this to make it work on all platforms. Some snippets from the python documentation:

args should be a sequence of program arguments or else a single string. ... Unless otherwise stated, it is recommended to pass args as a sequence. ... If shell is True, it is recommended to pass args as a string rather than as a sequence. ... The only time you need to specify shell=True on Windows is when the command you wish to execute is built into the shell (e.g. dir or copy). You do not need shell=True to run a batch file or console-based executable.

I created separate logic to run on Windows platforms. It will be released as AsciiDoxy 0.7.5

silvester747 commented 3 years ago

Testing on Windows showed that shell=True is still required. Updated the commit.