mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Allow DivinerPublisher
to be specified as a flag
Summary: Allow the `DivinerPublisher` subclass to be specified via `./bin/divner generate --publisher ...`. In particular, this allows use of the (mostly broken) `DivinerStaticPublisher`. Test Plan: Ran `./bin/diviner generate --publisher DivinerStaticPublisher` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11588
This commit is contained in:
parent
ec39649449
commit
d4b78af102
2 changed files with 30 additions and 8 deletions
|
@ -42,6 +42,7 @@ abstract class DivinerPublisher {
|
|||
$this->atomCache = $cache;
|
||||
$graph_map = $this->atomCache->getGraphMap();
|
||||
$this->atomGraphHashToNodeHashMap = array_flip($graph_map);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getAtomFromGraphHash($graph_hash) {
|
||||
|
|
|
@ -19,6 +19,12 @@ final class DivinerGenerateWorkflow extends DivinerWorkflow {
|
|||
'param' => 'path',
|
||||
'help' => pht('Path to a Diviner book configuration.'),
|
||||
),
|
||||
array(
|
||||
'name' => 'publisher',
|
||||
'param' => 'class',
|
||||
'help' => pht('Specify a subclass of %s.', 'DivinerPublisher'),
|
||||
'default' => 'DivinerLivePublisher',
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -164,7 +170,22 @@ final class DivinerGenerateWorkflow extends DivinerWorkflow {
|
|||
$this->buildAtomCache();
|
||||
$this->buildGraphCache();
|
||||
|
||||
$this->publishDocumentation($args->getArg('clean'));
|
||||
$publisher_class = $args->getArg('publisher');
|
||||
$symbols = id(new PhutilSymbolLoader())
|
||||
->setName($publisher_class)
|
||||
->setConcreteOnly(true)
|
||||
->setAncestorClass('DivinerPublisher')
|
||||
->selectAndLoadSymbols();
|
||||
if (!$symbols) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
"Publisher class '%s' must be a concrete subclass of %s.",
|
||||
$publisher_class,
|
||||
'DivinerPublisher'));
|
||||
}
|
||||
$publisher = newv($publisher_class, array());
|
||||
|
||||
$this->publishDocumentation($args->getArg('clean'), $publisher);
|
||||
}
|
||||
|
||||
/* -( Atom Cache )--------------------------------------------------------- */
|
||||
|
@ -497,18 +518,18 @@ final class DivinerGenerateWorkflow extends DivinerWorkflow {
|
|||
return md5(serialize($inputs)).'G';
|
||||
}
|
||||
|
||||
private function publishDocumentation($clean) {
|
||||
private function publishDocumentation($clean, DivinerPublisher $publisher) {
|
||||
$atom_cache = $this->getAtomCache();
|
||||
$graph_map = $atom_cache->getGraphMap();
|
||||
|
||||
$this->log(pht('PUBLISHING DOCUMENTATION'));
|
||||
|
||||
$publisher = new DivinerLivePublisher();
|
||||
$publisher->setDropCaches($clean);
|
||||
$publisher->setConfig($this->getAllConfig());
|
||||
$publisher->setAtomCache($atom_cache);
|
||||
$publisher->setRenderer(new DivinerDefaultRenderer());
|
||||
$publisher->publishAtoms(array_values($graph_map));
|
||||
$publisher
|
||||
->setDropCaches($clean)
|
||||
->setConfig($this->getAllConfig())
|
||||
->setAtomCache($atom_cache)
|
||||
->setRenderer(new DivinerDefaultRenderer())
|
||||
->publishAtoms(array_values($graph_map));
|
||||
|
||||
$this->log(pht('Done.'));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue