Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diviner/workflow/DivinerGenerateWorkflow.php
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | if ($book) { | ||||
if (!$books) { | if (!$books) { | ||||
throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
pht( | pht( | ||||
"There are no Diviner '%s' files anywhere beneath the current ". | "There are no Diviner '%s' files anywhere beneath the current ". | ||||
"directory. Use '%s' to specify a documentation book to generate.", | "directory. Use '%s' to specify a documentation book to generate.", | ||||
'.book', | '.book', | ||||
'--book <book>')); | '--book <book>')); | ||||
} else { | } else { | ||||
$this->log(pht('Found %s book(s).', new PhutilNumber(count($books)))); | $this->log(pht('Found %s book(s).', phutil_count($books))); | ||||
} | } | ||||
} | } | ||||
foreach ($books as $book) { | foreach ($books as $book) { | ||||
$short_name = basename($book); | $short_name = basename($book); | ||||
$this->log(pht('Generating book "%s"...', $short_name)); | $this->log(pht('Generating book "%s"...', $short_name)); | ||||
$this->generateBook($book, $args); | $this->generateBook($book, $args); | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | /* -( Atom Cache )--------------------------------------------------------- */ | ||||
private function buildAtomCache() { | private function buildAtomCache() { | ||||
$this->log(pht('BUILDING ATOM CACHE')); | $this->log(pht('BUILDING ATOM CACHE')); | ||||
$file_hashes = $this->findFilesInProject(); | $file_hashes = $this->findFilesInProject(); | ||||
$this->log( | $this->log( | ||||
pht( | pht( | ||||
'Found %s file(s) in project.', | 'Found %s file(s) in project.', | ||||
new PhutilNumber(count($file_hashes)))); | phutil_count($file_hashes))); | ||||
$this->deleteDeadAtoms($file_hashes); | $this->deleteDeadAtoms($file_hashes); | ||||
$atomize = $this->getFilesToAtomize($file_hashes); | $atomize = $this->getFilesToAtomize($file_hashes); | ||||
$this->log( | $this->log( | ||||
pht( | pht( | ||||
'Found %s unatomized, uncached file(s).', | 'Found %s unatomized, uncached file(s).', | ||||
new PhutilNumber(count($atomize)))); | phutil_count($atomize))); | ||||
$file_atomizers = $this->getAtomizersForFiles($atomize); | $file_atomizers = $this->getAtomizersForFiles($atomize); | ||||
$this->log( | $this->log( | ||||
pht( | pht( | ||||
'Found %s file(s) to atomize.', | 'Found %s file(s) to atomize.', | ||||
new PhutilNumber(count($file_atomizers)))); | phutil_count($file_atomizers))); | ||||
$futures = $this->buildAtomizerFutures($file_atomizers); | $futures = $this->buildAtomizerFutures($file_atomizers); | ||||
$this->log( | $this->log( | ||||
pht( | pht( | ||||
'Atomizing %s file(s).', | 'Atomizing %s file(s).', | ||||
new PhutilNumber(count($file_atomizers)))); | phutil_count($file_atomizers))); | ||||
if ($futures) { | if ($futures) { | ||||
$this->resolveAtomizerFutures($futures, $file_hashes); | $this->resolveAtomizerFutures($futures, $file_hashes); | ||||
$this->log(pht('Atomization complete.')); | $this->log(pht('Atomization complete.')); | ||||
} else { | } else { | ||||
$this->log(pht('Atom cache is up to date, no files to atomize.')); | $this->log(pht('Atom cache is up to date, no files to atomize.')); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | private function buildGraphCache() { | ||||
$dirty_symbols = array(); | $dirty_symbols = array(); | ||||
$dirty_nhashes = array(); | $dirty_nhashes = array(); | ||||
$del_atoms = array_diff_key($symbol_map, $atoms); | $del_atoms = array_diff_key($symbol_map, $atoms); | ||||
$this->log( | $this->log( | ||||
pht( | pht( | ||||
'Found %s obsolete atom(s) in graph.', | 'Found %s obsolete atom(s) in graph.', | ||||
new PhutilNumber(count($del_atoms)))); | phutil_count($del_atoms))); | ||||
foreach ($del_atoms as $nhash => $shash) { | foreach ($del_atoms as $nhash => $shash) { | ||||
$atom_cache->deleteSymbol($nhash); | $atom_cache->deleteSymbol($nhash); | ||||
$dirty_symbols[$shash] = true; | $dirty_symbols[$shash] = true; | ||||
$atom_cache->deleteEdges($nhash); | $atom_cache->deleteEdges($nhash); | ||||
$atom_cache->deleteGraph($nhash); | $atom_cache->deleteGraph($nhash); | ||||
} | } | ||||
$new_atoms = array_diff_key($atoms, $symbol_map); | $new_atoms = array_diff_key($atoms, $symbol_map); | ||||
$this->log( | $this->log( | ||||
pht( | pht( | ||||
'Found %s new atom(s) in graph.', | 'Found %s new atom(s) in graph.', | ||||
new PhutilNumber(count($new_atoms)))); | phutil_count($new_atoms))); | ||||
foreach ($new_atoms as $nhash => $ignored) { | foreach ($new_atoms as $nhash => $ignored) { | ||||
$shash = $this->computeSymbolHash($nhash); | $shash = $this->computeSymbolHash($nhash); | ||||
$atom_cache->addSymbol($nhash, $shash); | $atom_cache->addSymbol($nhash, $shash); | ||||
$dirty_symbols[$shash] = true; | $dirty_symbols[$shash] = true; | ||||
$atom_cache->addEdges($nhash, $this->getEdges($nhash)); | $atom_cache->addEdges($nhash, $this->getEdges($nhash)); | ||||
Show All 22 Lines | while ($symbol_stack) { | ||||
$symbol_stack[] = $src_hash; | $symbol_stack[] = $src_hash; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$this->log( | $this->log( | ||||
pht( | pht( | ||||
'Found %s affected atoms.', | 'Found %s affected atoms.', | ||||
new PhutilNumber(count($dirty_nhashes)))); | phutil_count($dirty_nhashes))); | ||||
foreach ($dirty_nhashes as $nhash => $ignored) { | foreach ($dirty_nhashes as $nhash => $ignored) { | ||||
$atom_cache->addGraph($nhash, $this->computeGraphHash($nhash)); | $atom_cache->addGraph($nhash, $this->computeGraphHash($nhash)); | ||||
} | } | ||||
$this->log(pht('Writing graph cache.')); | $this->log(pht('Writing graph cache.')); | ||||
$atom_cache->saveGraph(); | $atom_cache->saveGraph(); | ||||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |