function run($path) { $Sc =& $this->Project->Sc; // Default template if (!isset($this->options['template']) || is_string($this->options['template'])) { $this->options['template'] = 'default'; } // Get template $template_path = SCRIBE_PATH . 'templates/html.' . $this->options['template']; // Does it exist? if (!is_dir($template_path)) { ScStatus::error("Can't find template " . $this->options['template']); } // Clear the folder foreach (glob("{$path}/*") as $file) { @unlink($file); } // Make the assets folder foreach ($this->folders as $folder) { @mkdir("{$path}/{$folder}", 0744, TRUE); foreach (glob("{$path}/{$folder}/*") as $file) { @unlink($file); } } // Fill the assets folder foreach (glob($template_path . DS . 'assets' . DS . '*') as $file) { @copy($file, $path . DS . 'assets' . DS . basename($file)); } // Output // $this->out_content_index($path, $template_path); $this->out_singles($path, $template_path); $this->out_full($path, $template_path); }
function build() { /* Function: build() * Builds the project. * * Description: * This is the main function that builds the documentation. This is * called when the user types `ss build` in the command line (or just * plain `ss` as it's the default action). It does the things below: * * 1. The source path is scanned for files recursively, and it'll * delegate each file to it's respective `reader` to be read. * * 2. These readers will parse out the files and call [[register()]] * when it finds a block. * * 3. It checks the outputs to be made (defined in the configuration * file) and delegates to each output driver the task of producing * the documentation files. * * * References: * This is called by the default action of [[class Scribe]], * namely [[Scribe::do_build()]]. Being the default action, this fires * up when the user types `ss` in the command line. */ ScStatus::status('Starting build process:'); // Scan the files ScStatus::updateStart("Scanning files"); $file_count = 0; $options = array('recursive' => 1, 'mask' => '/./', 'fullpath' => 1); // Take the exclusions list into consideration if (isset($this->options['exclude'])) { $options['exclude'] = array(); foreach ($this->options['exclude'] as $ex) { $options['exclude'][] = ':' . $ex . ':'; /* Regex, you see */ } } // For each source path... foreach ((array) $this->options['src_path'] as $path) { // Parse each of the files $files = aeScandir($path, $options); foreach ($files as $file) { // Find out which reader it's assigned to foreach ($this->options['include'] as $spec => $reader_name) { if (preg_match("~{$spec}~", $file) == 0) { continue; } // Show status of what file we're reading $file_min = substr(realpath($file), 1 + strlen(realpath($this->cwd))); ScStatus::update("[{$reader_name}] {$file_min}"); $file_count++; // And read it $this->registerStart(); $reader = $this->Sc->Readers[$reader_name]; $blocks = $reader->parse($file, $this); break; } } } ScStatus::updateDone("{$file_count} files scanned."); $this->_doPostBuild(); $this->_loadOutputDrivers(); // Spit out the outputs. // Do this for every output defined... foreach ($this->options['output'] as $id => $output_options) { // Make sure we have an output driver if (!isset($output_options['driver'])) { return ScStatus::error("No driver defined for output {$id}"); } // Load it and make sure it exists $driver =& $this->Sc->loadOutputDriver($output_options['driver'], $this, $options); $driver =& $this->outputs[$id]; if (!$driver) { continue; } // Initialize ScStatus::updateStart('Writing ' . $output_options['driver'] . ' output'); $path = $output_options['path']; // Mkdir the path $path = $this->cwd . DS . $path; $result = @mkdir($path, 0744, true); if (!is_dir($path)) { return $this->Sc->error("Can't create folder for {$driver} output."); } // Run $driver->run($path); ScStatus::updateDone('Done.'); } ScStatus::status('Build complete.'); $output = serialize($this->Sc); }
function do_makeconfig() { ob_start(); @(include SCRIBE_PATH . '/include/misc.defaultconfig.php'); $contents = ob_get_clean(); $output_fname = getcwd() . DS . 'sourcescribe.conf'; if (is_file($output_fname)) { return ScStatus::error("A configuration file already exists!"); } file_put_contents($output_fname, $contents); }
function _verifyBlockTypes() { /* Function: _verifyBlockTypes() * Verifies the block types; called by [[load()]]. * * Returns: * TRUE on success; dies if something is wrong. * * [Private, grouped under "Private functions"] */ if (!isset($this->options['block_types'])) { return ScStatus::error("Block types is not valid!"); } if (!is_array($this->options['block_types'])) { return ScStatus::error("Block types is not valid!"); } $this->options['type_keywords'] = array(); foreach ($this->options['block_types'] as $id => &$block_type) { if (!isset($block_type['title_plural'])) { $block_type['title_plural'] = strtoupper(substr($id, 0, 1)) . substr($id, 1, 999) . "s"; } if (!isset($block_type['has_brief'])) { $block_type['has_brief'] = FALSE; } if (!isset($block_type['parent_in_id'])) { $block_type['parent_in_id'] = array(); } if (!isset($block_type['tags'])) { $block_type['tags'] = array(); } if (!isset($block_type['priority'])) { $block_type['priority'] = NULL; } if (!isset($block_type['default_order'])) { $block_type['default_order'] = 0; } if (!is_array($block_type['tags'])) { $block_type['tags'] = (array) $block_type['tags']; } if (!is_array($block_type['parent_in_id'])) { $block_type['parent_in_id'] = (array) $block_type['parent_in_id']; } if (!isset($block_type['short'])) { $block_type['short'] = $id; } if (!isset($block_type['starts_group_for'])) { $block_type['starts_group_for'] = array(); } if (!is_array($block_type['starts_group_for'])) { $block_type['starts_group_for'] = (array) $block_type['starts_group_for']; } if (!isset($block_type['synonyms'])) { $block_type['synonyms'] = array(); } if (!is_array($block_type['synonyms'])) { $block_type['synonyms'] = (array) $block_type['synonyms']; } $this->options['type_keywords'][$id] = $id; foreach ($block_type['synonyms'] as $alias) { $this->options['type_keywords'][$alias] = $id; } } return TRUE; }