code-lts / doctum

A php API documentation generator, fork of Sami
https://doctum.long-term.support/
MIT License
300 stars 32 forks source link

Branches with forward slashes in the name are not supported #63

Open tiller1010 opened 10 months ago

tiller1010 commented 10 months ago

If I use branches with forward slashes in the name, then the version dropdown includes a "%2F" for the slash in the option values.

This config...

<?php

use Doctum\Version\GitVersionCollection;

$versions = GitVersionCollection::create(__DIR__ . '/src')
    ->add('support/1.0.x', '1.0.x branch')
    ->add('support/2.3.x', '2.3.x branch')
    ->add('feature/psr-4', 'main branch');

return new Doctum\Doctum(__DIR__ . '/src', [
    'title' => 'Module',
    'build_dir' => __DIR__.'/doctum_build/%version%',
    'cache_dir' => __DIR__.'/doctum_cache/%version%',
    'versions' => $versions,
]);

Produces this dropdown

<select class="form-control" id="version-switcher" name="version">
    <option value="../support%2F1.0.x/index.html" data-version="support/1.0.x">1.0.x branch</option>
    <option value="../support%2F2.3.x/index.html" data-version="support/2.3.x" selected="">2.3.x branch</option>
    <option value="../feature%2Fpsr-4/index.html" data-version="feature/psr-4">main branch</option>
</select>

The sub-directories are created just fine though.

$ ls doctum_build/support/
1.0.x/  2.3.x/

The links also start from the wrong directory because of this. ../support%2F1.0.x/index.html should be ../../support/1.0.x/index.html.

williamdes commented 10 months ago

Hello @tiller1010 This is quite an interesting one, I will keep this in my unread emails to try to process it asap If you wish to open a PR to the v5.5.x branch go ahead