Permalink
Browse files

closed #329: if .xml is suffixed to the -t option then it is assumed …

…you want to use that specific filename; otherwise it is assumed that you want to save to folder
  • Loading branch information...
1 parent 809e64d commit 8c8921ade056d31bdc6a70ed304875b15e8f5fab @mvriel mvriel committed Jan 6, 2012
View
@@ -21,6 +21,10 @@
* FIXED: Arrays with multiple elements were cut-off for property defaults
* FIXED: When using the `declare` command as first in the file then the
file-level docblock is not recognized
+* ADDED: Now it is possible to provide a target file with the parsing action.
+ Instead of always generating to structure.xml you can provide anything
+ as long as it is suffixed with .xml; in addition to only providing a
+ folder.
12/24/2011: Version 0.17.2
--------------------------
@@ -144,25 +144,34 @@ public function getTarget()
);
}
- // if the folder does not exist at all, create it
- if (!file_exists($target)) {
- mkdir($target, 0744, true);
- }
+ // if the target does not end with .xml, assume it is a folder
+ if (substr($target, -4) != '.xml') {
+ // if the folder does not exist at all, create it
+ if (!file_exists($target)) {
+ mkdir($target, 0744, true);
+ }
- if (!is_dir($target)) {
- throw new Zend_Console_Getopt_Exception(
- 'The given location "' . $target . '" is not a folder'
- );
+ if (!is_dir($target)) {
+ throw new Zend_Console_Getopt_Exception(
+ 'The given location "' . $target . '" is not a folder'
+ );
+ }
+
+ $path = realpath($target);
+ $target = $path . DIRECTORY_SEPARATOR . 'structure.xml';
+ } else {
+ $path = realpath(dirname($target));
+ $target = $path . DIRECTORY_SEPARATOR . basename($target);
}
- if (!is_writable($target)) {
+ if (!is_writable($path)) {
throw new Zend_Console_Getopt_Exception(
'The given path "' . $target . '" either does not exist or is '
. 'not writable.'
);
}
- return realpath($target);
+ return $target;
}
/**
@@ -367,7 +376,7 @@ public function execute()
$parser = new DocBlox_Parser();
$parser->setTitle(htmlentities($this->getTitle()));
- $parser->setExistingXml($this->getTarget() . '/structure.xml');
+ $parser->setExistingXml($this->getTarget());
$parser->setForced($this->getForce());
$parser->setMarkers($this->getMarkers());
$parser->setIgnoredTags($this->getIgnoreTags());
@@ -380,7 +389,7 @@ public function execute()
try {
// save the generate file to the path given as the 'target' option
file_put_contents(
- $this->getTarget() . '/structure.xml',
+ $this->getTarget(),
$parser->parseFiles($files, $this->getSourcecode())
);
} catch (Exception $e) {
@@ -177,12 +177,10 @@ public function execute()
$transform = new DocBlox_Task_Project_Transform();
if ($this->getTarget() !== null) {
- $transform->setTarget($task->getTarget());
+ $transform->setTarget(dirname($task->getTarget()));
}
$transform->setTemplate($this->getTemplate());
- $transform->setSource(
- $task->getTarget() . DIRECTORY_SEPARATOR . 'structure.xml'
- );
+ $transform->setSource($task->getTarget());
$transform->setVerbose($task->getVerbose());
$transform->setQuiet($task->getQuiet());
$transform->setParseprivate($this->getParseprivate());
@@ -45,7 +45,7 @@ protected function configure()
{
$this->addOption(
's|source', '-s',
- 'Path where the structure.xml is located (optional, defaults to '
+ 'Path where the XML source file is located (optional, defaults to '
. '"output/structure.xml")'
);
$this->addOption(
@@ -29,7 +29,7 @@ Usage:
-h [--help] Show this help message
-q [--quiet] Silences the output and logging
-c [--config] [STRING] Configuration filename OR "none", when this option is omitted DocBlox tries to load the docblox.xml or docblox.dist.xml from the current working directory
--s [--source] [STRING] Path where the structure.xml is located (optional, defaults to "output/structure.xml")
+-s [--source] [STRING] Path where the XML source file is located (optional, defaults to "output/structure.xml")
-t [--target] [STRING] Path where to store the generated output (optional, defaults to "output")
--template [STRING] Name of the template to use (optional, defaults to "default")
-v [--verbose] Outputs any information collected by this application, may slow down the process slightly

0 comments on commit 8c8921a

Please sign in to comment.