<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  $package= 'xp.doclet';

  uses('text.doclet.RootDoc', 'util.cmd.ParamString');

  /**
   * Command line doclet runner
   *
   * @purpose  RootDoc CLI adaptor
   */
  class xpdocletRunner extends Object {
  
    /**
     * Runner method
     *
     */
    public static function main(array $args) {
      if (sizeof($args) < 1) {
        Console::$err->writeLine('*** No doclet classname given');
        return -1;
      }

      $class= XPClass::forName($args[0]);
      if (!$class->isSubclassOf('text.doclet.Doclet')) {
        Console::$err->writeLine('*** ', $class, ' is not a doclet');
        return -2;
      }

      RootDoc::start($class->newInstance(), new ParamString($args));
    }
  }
?><commit_msg>- Add usage<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  $package= 'xp.doclet';

  uses('text.doclet.RootDoc', 'util.cmd.ParamString');

  /**
   * Command line doclet runner
   * ~~~~~~~~~~~~~~~~~~~~~~~~~~
   *
   * Usage:
   * <pre>
   *   doclet class [options] name [name [name...]]
   * </pre>
   * Names can be one or more of:
   * <ul>
   *   <li>{package.name}.*: All classes inside a given package</li>
   *   <li>{package.name}.**: All classes inside a given package and all it subpackages</li>
   *   <li>{qualified.class.Name}: A fully qualified class name</li>
   * </ul> 
   *
   * @purpose  Tool
   */
  class xpdocletRunner extends Object {

    /**
     * Converts api-doc "markup" to plain text w/ ASCII "art"
     *
     * @param   string markup
     * @return  string text
     */
    protected static function textOf($markup) {
      $line= str_repeat('=', 72);
      return strip_tags(preg_replace(array(
        '#<pre>#', '#</pre>#', '#<li>#',
      ), array(
        $line, $line, '* ',
      ), trim($markup)));
    }

    /**
     * Displays usage and exits
     *
     */
    protected static function usage() {
      Console::$err->writeLine(self::textOf(XPClass::forName(xp::nameOf(__CLASS__))->getComment()));
      exit(1);
    }
  
    /**
     * Runner method
     *
     */
    public static function main(array $args) {
      if (!$args) self::usage();

      $class= XPClass::forName($args[0]);
      if (!$class->isSubclassOf('text.doclet.Doclet')) {
        Console::$err->writeLine('*** ', $class, ' is not a doclet');
        return -2;
      }

      RootDoc::start($class->newInstance(), new ParamString($args));
    }
  }
?>
{'fraction_non_alphanumeric': 0.18647458983593437, 'fraction_numerical': 0.003601440576230492, 'mean_word_length': 2.4106412005457027, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2209875', 'n_tokens_mistral': 850, 'n_tokens_neox': 827, 'n_words': 192}