public function process(Project $project) { if ($project->classes) { if (!file_exists("{$this->dir}/classes")) { if (!mkdir("{$this->dir}/classes", 0755, true)) { throw new \RuntimeException("Could not create directory {$this->dir}/classes for mdocs"); } } foreach ($project->classes as $class) { $doc = []; $doc["header"] = Flags::decode($class->flags & Flags::CLASS_TYPES) . " " . $class->name; $doc[] = str_pad("", strlen($doc["header"]), "="); $doc[] = ""; if ($class->parent) { $doc[] = "Parent: [" . $class->parent->name . "](#xxx)"; } if ($class->interfaces) { $doc[] = "Interfaces: " . implode(", ", array_keys($class->interfaces)); } if ($class->traits) { $doc[] = "Traits: " . implode(", ", array_keys($class->traits)); } $doc[] = $class->description; if ($class->constants) { $doc[] = ""; $doc[] = "## Constants"; foreach ($class->constants as $constant) { $doc[] = "**{$constant->short}** `{$constant->value}`"; } } if ($class->properties) { $doc[] = ""; $doc[] = "## Properties"; foreach ($class->properties as $property) { $doc[] = "**{$property->name}** `{$property->value}`"; } } if ($class->methods) { $doc[] = ""; $doc[] = "## Methods"; foreach ($class->methods as $method) { $doc[] = $method->dump() . " {$method->description}"; } } FS::put("{$this->dir}/classes/" . str_replace('\\', '-', $class->name) . '.md', implode("\n", $doc)); } } }
public function dump($tab = "") { return parent::dump($tab) . " [" . Flags::decode($this->flags) . "]"; }
/** * @inheritdoc */ public function dump($tab = "") { $inf = ["line: {$this->line}"]; if ($this->parent) { $inf[] = "parent: {$this->parent->name}"; } if ($this->parents) { $inf[] = "parents: " . implode(", ", array_keys($this->parents)); } if ($this->interfaces) { $inf[] = "interfaces: " . implode(", ", array_keys($this->interfaces)); } foreach (['constants', 'properties', 'methods'] as $entities) { if ($this->{$entities}) { $inf[] = ""; } foreach ($this->{$entities} as $entity) { /* @var EntityInterface $entity */ $inf[] = $entity->dump(); } } $access = Flags::decode($this->flags & ~Flags::CLASS_TYPES); return Flags::decode($this->flags & Flags::CLASS_TYPES) . " {$this->name} " . ($access ? "[{$access}] " : "") . "{\n{$tab} " . implode("\n{$tab} ", $inf) . "\n{$tab}}\n"; }