Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backslashes in output filenames #384

Closed
deframe opened this issue Mar 16, 2012 · 7 comments
Closed

Backslashes in output filenames #384

deframe opened this issue Mar 16, 2012 · 7 comments
Assignees
Labels
Milestone

Comments

@deframe
Copy link

deframe commented Mar 16, 2012

phpDocumentor seems to include the backslash namespace delimiter in output filenames. For example, running it on a class with the following doc:

... Will produce "classes/db_\App_Test.html" in the output directory. This behavior can be confirmed by looking at some the filenames on http://demo.phpdoc.org/Responsive/

Filenames containing backslashes do not work on some platforms (e.g. Windows) so this really needs to be rectified in some way.

@mvriel
Copy link
Member

mvriel commented Mar 16, 2012

Thanks for mentioning this! We will investigate this as one of the top prio things! (can't have windows breaking can we ;))

@mvriel
Copy link
Member

mvriel commented Mar 17, 2012

It would be best to do an XSL replacement of the \ with . when working with files; using _ could cause conflicts with classes using underscores whilst the . is prohibited from use in a class name.

Since we are required to work with XSL 1.0 (which is a shame) a custom replace template needs to be added (as described here: http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx)

@ghost ghost assigned mvriel Mar 17, 2012
@deframe
Copy link
Author

deframe commented Mar 17, 2012

The generated filenames would also have to change, though I'm not sure if that should happen in phpDocumentor_Plugin_Core_Transformer_Writer_Xsl::transform() or phpDocumentor_Transformer::generateFilename()

Regarding the XSL replacements, would it be easier passing in an extra variable into the stylesheet? (e.g. file_name as well as full_name)

I'm not really familiar with the doxblox/phpDocumentor source code (or XSLT for that matter!) so I could be barking up the wrong tree here.

@mvriel
Copy link
Member

mvriel commented Mar 18, 2012

You are definitely going in the right direction; the phpDocumentor_Plugin_Core_Transformer_Writer_Xsl writer needs to sanitize the 'artifact' (destination filename) and replace all illegal characters with dots.

Since the 'artifact' for the XSL writer may contain a variable should this sanitation be done after the variable contents are injected.

Regarding providing an additional filename:
I had done that with previous versions of the templates but this approach did not provide the versatility that was needed. I used to generate a file for each source file now we generate files for each package, namespace and class. The XSL writer does not know which is which (and frankly: shouldn't care); thus it is hard to pass all files up front (don't forget; inside each document may be links to other documents).

As such it is more versatile to generate the required filename from within the XSL template

@CloCkWeRX
Copy link
Contributor

@mvriel Would the area to fix be in phpDocumentor_Transformer::generateFilename(), or somewhere else?

@mvriel
Copy link
Member

mvriel commented Mar 24, 2012

@CloCkWeRX that is indeed the location + that the XSL templates need to transform the path.
Another thing would be to remove the db_ prefix but that introduces bugs in the other templates. For that to be possible should the other templates be refactored to at least put their generated content in a sub-folder.

(currently the other templates generate their content in the output root folder; which is a problem if you are parsing a file called index.php because the output would be named index.html and thus overwrite the template's own index.html)

@mvriel mvriel closed this as completed in f5b5182 Mar 25, 2012
@mvriel
Copy link
Member

mvriel commented Mar 25, 2012

I have altered the paths to use a . instead of namespace slashes

CloCkWeRX pushed a commit to CloCkWeRX/phpDocumentor2 that referenced this issue Mar 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants