Skip to content

Apidoc: Handle files with the same name from different sourceDirs #45

Description

@yii-bot

This issue has originally been reported by @schmunk42 at yiisoft/yii2#3547.
Moved here by @cebe.


As you can specify different sourceDirs when rendering a guide, apidoc should also be able to correctly link to different files, even if they have the same source name.

Eg, if you specify two directories and both contain a README.md file you'll see both files in the index in the left sidebar, but you can access only one of them, since they have the same filename when rendered.

I played around with something like this:

protected function generateGuideFileName($file)
{
    $uniqueFileName = static::GUIDE_PREFIX . substr(sha1($file),0,6) . '-' . basename($file, '.md');
    return $uniqueFileName . '.html';
}

But it needs to be handled in more places, like generateGuideUrl.

What do you think about the approach adding a hash to the filename, any other ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions