phpDocumentor / phpDocumentor/guides

[Bug]: Relative paths for Literalincludes in included files are resolved incorretly

Open
#1,068 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
36
Forks
22
Avg merge
2d 2h
Merged PRs (30d)
24

Description

Summary

Relative paths are resolved from the location where the file is included not from the location oft the file itself

Code snippet that reproduces the problem

I have the following directory structures:

image

They are all included in Index.rst

Now if one of the properties or examples has a literalinclude using relativ paths I would expect the following to work:

..  literalinclude:: ../_CodeSnippets/_creationOptions.php
    :language: php
    :caption: EXT:my_extension/Configuration/TCA/Overrides/tt_content.php

But have to do

..  literalinclude:: _CodeSnippets/_creationOptions.php
    :language: php
    :caption: EXT:my_extension/Configuration/TCA/Overrides/tt_content.php

Or an absolute path like


..  literalinclude:: /Types/_CodeSnippets/_creationOptions.php
    :language: php
    :caption: EXT:my_extension/Configuration/TCA/Overrides/tt_content.php
Expected output

I would expect

..  literalinclude:: ../_CodeSnippets/_creationOptions.php
    :language: php
    :caption: EXT:my_extension/Configuration/TCA/Overrides/tt_content.php

To work

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the shown included-file structure and the relative literalinclude examples. Compare resolution from the including file with resolution from the file containing the directive; done means the ../_CodeSnippets/_creationOptions.php path works as shown while preserving the expected code output.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.