function main() { BoostSiteTools\CommandLineOptions::parse(NEW_LIBRARIES_USAGE); $libraries = BoostLibraries::load(); $master = $libraries->get_for_version('master'); $unreleased_libs = array(); foreach ($master as $lib) { if ($lib['boost-version']->is_unreleased()) { $unreleased_libs[$lib['name']] = $lib; } } if ($unreleased_libs) { ksort($unreleased_libs, SORT_NATURAL | SORT_FLAG_CASE); $count = count($unreleased_libs); echo "For release notes:\n\n"; echo "[section New Libraries]\n\n"; foreach ($unreleased_libs as $lib) { echo "* [phrase library..[@/{$lib['documentation']} {$lib['name']}]:]\n"; echo " {$lib['description']}\n\n"; } echo "[endsection]\n\n"; } else { echo "No new libraries yet.\n"; } }
function main() { $libraries = BoostLibraries::load(); $master = $libraries->get_for_version('master'); $unreleased_libs = []; foreach ($master as $lib) { if ($lib['boost-version']->is_unreleased()) { $unreleased_libs[$lib['name']] = $lib; } } if ($unreleased_libs) { ksort($unreleased_libs, SORT_NATURAL | SORT_FLAG_CASE); $count = count($unreleased_libs); echo "For release notes:\n\n"; echo "[section New Libraries]\n\n"; foreach ($unreleased_libs as $lib) { echo "* [phrase library..[@/{$lib['documentation']} {$lib['name']}]:]\n"; echo " {$lib['description']}\n\n"; } echo "[endsection]\n\n"; echo "For root index file:\n\n"; $library_links = []; foreach ($unreleased_libs as $lib) { $library_links[] = "<a href=\"" . filesystem_doc_link($lib) . "\">{$lib['name']}</a>"; } echo " <p>The release includes {$count} new " . ($count === 1 ? "library" : "libraries") . "\n"; echo " (" . implode(",\n ", $library_links) . "),\n"; } }
function main() { $args = $_SERVER['argv']; $boost_root = null; switch (count($args)) { case 2: $boost_root = $args[1]; break; default: echo "Usage: create-module-metadata.php boost_root\n"; exit(1); } $library_details = BoostLibraries::from_xml_file(__DIR__ . '/../doc/libraries.xml')->get_for_version(BoostVersion::develop()); $super_project = new BoostSuperProject($boost_root); $git_submodules = $super_project->get_modules(); // Split the libraries up into modules. $libraries_by_module = array(); foreach ($library_details as $library) { $module = $library['module']; if (!isset($git_submodules[$module])) { echo "Unknown module: {$module}\n"; continue; } if (isset($library['documentation'])) { $doc_url = $library['documentation']; $module_base = $git_submodules[$module]['path']; if ($doc_url == $module_base) { $doc_url = ''; } else { if (strpos($doc_url, "{$module_base}/") === 0) { $doc_url = substr($doc_url, strlen("{$module_base}/")); } else { $doc_url = "/{$doc_url}"; } } if (!$doc_url) { unset($library['documentation']); } else { $library['documentation'] = $doc_url; } } $libraries_by_module[$module][] = $library; } // Write the module metadata foreach ($libraries_by_module as $module => $libraries) { $module_libraries = BoostLibraries::from_array($libraries); $module_dir = "{$boost_root}/{$git_submodules[$module]['path']}"; $meta_dir = "{$module_dir}/meta"; $meta_file = "{$module_dir}/meta/libraries.json"; if (!is_dir($module_dir)) { echo "Module '{$module}' doesn't exist at '{$module_dir}'\n"; continue; } if (!is_dir($meta_dir)) { mkdir($meta_dir); } file_put_contents($meta_file, $module_libraries->to_json(array('boost-version', 'update-version', 'module')) . "\n"); } }
function display() { // TODO: Specifying the version only works *after* a release, as // new libraries will still have develop/master as their // version. This works for now as version is always // master/develop, but might change in the future. $version = BoostVersion::from(array_key_exists('version', $this->args) ? $this->args['version'] : 'master'); $page = $this->args['page']; $libs = BoostLibraries::load(); $categorized = $libs->get_categorized_for_version($version, 'name', 'BoostLibraries::filter_released'); // TODO: Shouldn't really have to sort this here. uasort($categorized, function ($a, $b) { $a = $a['title']; $b = $b['title']; if ($a === 'Miscellaneous') { $a = 'ZZZZZZZZ'; } if ($b === 'Miscellaneous') { $b = 'ZZZZZZZZ'; } return $a > $b ?: ($a < $b ? -1 : 0); }); $alphabetic = $libs->get_for_version($version, 'name', 'BoostLibraries::filter_released'); $params = array('categorized' => array(), 'alphabetic' => array(), 'unreleased_libs' => array(), 'unreleased_lib_count' => 0); foreach ($categorized as $category) { $template_value = $category; $template_value['libraries'] = array(); foreach ($category['libraries'] as $index => $library) { $template_value['libraries'][] = $this->rewrite_library($library, $index); } $params['categorized'][] = $template_value; } foreach ($alphabetic as $index => $library) { $params['alphabetic'][] = $this->rewrite_library($library, $index); } if ($version->is_unreleased()) { $index = 0; foreach ($alphabetic as $library) { if ($library['boost-version']->is_unreleased() || $library['boost-version']->is_beta()) { $params['unreleased_libs'][] = $this->rewrite_library($library, $index++); } } } else { $index = 0; foreach ($alphabetic as $library) { if ($library['boost-version']->major() == $version->major() && $library['boost-version']->minor() == $version->minor()) { $params['unreleased_libs'][] = $this->rewrite_library($library, $index++); } } } $params['unreleased_lib_count'] = count($params['unreleased_libs']); // Better support for other branches? $template_dir = BOOST_REPOS_DIR . '/boost-' . ((string) $version == 'develop' ? 'develop' : 'master') . '/' . $page; echo BoostSimpleTemplate::render(file_get_contents($template_dir), $params); }
function main() { $args = $_SERVER['argv']; $location = null; switch (count($args)) { case 2: $location = $args[1]; break; default: echo "Usage: backdate-maintainers.php location\n"; exit(1); } // Get the library data, so that it can be updated with maintainers. // In case you're wondering why the result from get_for_version doesn't // use 'key' as its key, it's for historical reasons I think, might be // fixable. $libraries = BoostLibraries::from_xml_file(__DIR__ . '/../doc/libraries.xml'); $unknown_libs = array(); foreach (BoostSuperProject::run_process("cd \"{$location}\" && git tag") as $tag) { if (preg_match('@^boost-1\\.\\d+\\.\\d+$@', $tag)) { $library_details = $libraries->get_for_version($tag, null, 'BoostLibraries::filter_all'); $libs_index = array(); foreach ($library_details as $index => $details) { $libs_index[$details['key']] = $index; } foreach (BoostMaintainers::read_from_text(git_file($location, $tag, 'libs/maintainers.txt'))->maintainers as $key => $lib_maintainers) { if (isset($libs_index[$key])) { $index = $libs_index[$key]; $library_details[$index]['maintainers'] = $lib_maintainers; } else { $unknown_libs[$key][] = $tag; } } $update = array_map(function ($lib) { return new BoostLibrary($lib); }, $library_details); $libraries->update($tag, $update); } } file_put_contents(dirname(__FILE__) . '/../doc/libraries.xml', $libraries->to_xml()); $names = array_keys($unknown_libs); sort($names); echo "Unable to find libraries:\n"; foreach ($names as $lib) { echo "{$lib} from: " . implode(', ', $unknown_libs[$lib]) . "\n"; } }
function main() { $args = $_SERVER['argv']; if (count($args) != 3) { echo "Usage: update-maintainers.php location version\n"; exit(1); } $location = $args[1]; $version = $args[2]; $libraries = BoostLibraries::from_xml_file(__DIR__ . '/../doc/libraries.xml'); $unknown_libs = array(); $maintainers = BoostMaintainers::read_from_text(file($location . '/libs/maintainers.txt')); $library_details = $libraries->get_for_version($version, null); $libs_index = array(); foreach ($library_details as $index => $details) { if (isset($details['maintainers'])) { $maintainers->update_maintainer($details['key'], $details['maintainers']); } } file_put_contents($location . '/libs/maintainers.txt', $maintainers->write_to_text()); }
function main() { $options = BoostSiteTools\CommandLineOptions::parse("Usage: {} location version"); if (count($options->positional) != 2) { echo $options->usage_message(); exit(1); } $location = $options->positional[0]; $version = $options->positional[1]; $libraries = BoostLibraries::from_xml_file(__DIR__ . '/../doc/libraries.xml'); $unknown_libs = array(); $maintainers = BoostMaintainers::read_from_text(file($location . '/libs/maintainers.txt')); // TODO: Want to include hidden libraries here. $library_details = $libraries->get_for_version($version, null); $libs_index = array(); foreach ($library_details as $index => $details) { if (isset($details['maintainers'])) { $maintainers->update_maintainer($details['key'], $details['maintainers']); } } file_put_contents($location . '/libs/maintainers.txt', $maintainers->write_to_text()); }
/** * */ static function load() { return USE_SERIALIZED_INFO ? unserialize(file_get_contents(dirname(__FILE__) . '/../../generated/libraries.txt')) : BoostLibraries::from_xml_file(dirname(__FILE__) . '/../../doc/libraries.xml'); }
if (is_string($v) && $v != '') { $url_params .= $url_params ? '&' : '?'; $url_params .= urlencode($k) . '=' . urlencode($v); } } echo '<a href="' . html_encode($this->base_uri . $url_params) . '">', html_encode($description), '</a>'; } } function category_link($name) { $category = $this->categories[$name]; $this->option_link(isset($category['title']) ? $category['title'] : $name, 'view', 'category_' . $name); } } // Page variables $library_page = new LibraryPage($_GET, BoostLibraries::load()); if (BoostVersion::page()->is_numbered_release() && $library_page->libs->latest_version && BoostVersion::page()->compare($library_page->libs->latest_version) > 0) { BoostWeb::error_404($_SERVER['REQUEST_URI']); return; } // To avoid confusion, only show this page when there is actual documentation. // TODO: Maybe for versions without documentation, could display the list // with no links. // TODO: This duplicates the BoostDocumentation object in display_libs. $archive = new BoostDocumentation(array('fix_dir' => dirname(__FILE__) . '/fixes', 'archive_dir' => STATIC_DIR, 'use_http_expire_date' => true)); if (!is_dir($archive->documentation_dir())) { BoostWeb::error_404($_SERVER['REQUEST_URI']); return; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<?php require_once __DIR__ . '/../boost.php'; $libraries = BoostLibraries::from_xml('<?xml version="1.0" encoding="US-ASCII"?> <boost xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <categories> <category name="Math"> <title>Maths stuff.</title> </category> <category name="Generic"> <title>Nonbranded stuff.</title> </category> </categories> <library> <key>accumulators</key> <module>accumulators</module> <boost-version>1.36.0</boost-version> <name>Accumulators</name> <authors>Eric Niebler</authors> <description>Framework for incremental calculation, and collection of statistical accumulators.</description> <documentation>libs/accumulators/</documentation> <std-proposal>false</std-proposal> <std-tr1>false</std-tr1> <category>Math</category> </library> </boost> '); $accumulators_details = '{ "key" : "accumulators", "module": "accumulators", "boost-version": "1.36.0",
function main() { global $quiet; $options = BoostSiteTools\CommandLineOptions::parse(UPDATE_DOC_LIST_USAGE, array('quiet' => false)); $quiet = $options->flags['quiet']; $location = null; $version = null; switch (count($options->positional)) { case 2: $version = $options->positional[1]; case 1: $location = $options->positional[0]; case 0: break; default: echo $options->usage_message(); exit(1); } if ($version) { // BoostVersion dies if version is invalid. $version = BoostVersion::from($version); } $libs = BoostLibraries::from_xml_file(dirname(__FILE__) . '/../doc/libraries.xml'); $updates = array(); if ($location) { $real_location = realpath($location); if ($real_location && !is_dir($real_location)) { echo "Not a directory: {$location}\n"; exit(1); } $location = $real_location; // If this is not a git repo. // TODO: Don't output stderr. exec("cd \"{$location}\" && git rev-parse --git-dir", $output, $return_var); if ($return_var != 0) { if (!$version || !$version->is_numbered_release()) { echo "Error: Release version required for release.\n"; exit(1); } $updates[(string) $version] = read_metadata_from_filesystem($location, $version); } else { if (get_bool_from_array(BoostSuperProject::run_process("cd '{$location}' && git rev-parse --is-bare-repository"))) { if ($version) { $updates[(string) $version] = read_metadata_from_git($location, $version); } else { $updates[(string) 'master'] = read_metadata_from_git($location, 'master'); $updates[(string) 'develop'] = read_metadata_from_git($location, 'develop'); } } else { // TODO: Could get version from the branch in a git checkout. if (!$version) { echo "Error: Version required for local tree.\n"; exit(1); } $updates[(string) $version] = read_metadata_from_filesystem($location, $version); } } } if ($updates) { foreach ($updates as $update_version => $update) { $libs->update($update_version, $update); } } else { $libs->update(); } if (!$quiet) { echo "Writing to disk\n"; } file_put_contents(dirname(__FILE__) . '/../doc/libraries.xml', $libs->to_xml()); $libs->squash_name_arrays(); file_put_contents(dirname(__FILE__) . '/../generated/libraries.txt', serialize($libs)); }
/** * * @param string $location The location of the super project in the mirror. * @param BoostVersion $version The version of the release. * @param \BoostLibraries $libs The existing libraries. * @throws RuntimeException */ function read_metadata_from_release($location, $version, $libs) { // We don't have a list for modules, so have to work it out from the // existing library data. // If we're updating an old version, then use that as the basis, // For a new version, take the data from the master branch, as this // may contain new modules that aren't in a release yet. $equivalent_version = BoostVersion::$current->compare($version) >= 0 ? $version : BoostVersion::master(); // Grab the modules from the metadata. $module_for_keys = array(); foreach ($libs->get_for_version($equivalent_version) as $details) { $module_for_keys[$details['key']] = $details['module']; } // Scan release for metadata files. $module_paths = array(); foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator("{$location}/libs", FilesystemIterator::CURRENT_AS_SELF | FilesystemIterator::UNIX_PATHS)) as $info) { if ($info->isDot() && $info->getFilename() == '.') { $path = dirname($info->getSubPathname()); if (is_file("{$info->getPathname()}/libraries.json")) { $module_paths[] = "libs/" . dirname($path); } } } $updated_libs = array(); foreach ($module_paths as $path) { $json_path = "{$location}/{$path}/meta/libraries.json"; try { $libraries = BoostLibrary::read_libraries_json(file_get_contents($json_path)); // Get the module for each library. foreach ($libraries as $lib) { if (!isset($module_for_keys[$lib->details['key']])) { echo "No module for key: {$lib->details['key']}.\n"; } else { $lib->set_module($module_for_keys[$lib->details['key']], $path); } } $updated_libs = array_merge($updated_libs, $libraries); } catch (library_decode_exception $e) { echo "Error decoding metadata for module at {$json_path}:\n{$e->content()}\n"; } } return $updated_libs; }
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <?php // Returns true if the library is part of the current release of boost. function xmlentities($text) { return str_replace(array('&', '<', '>', '"', "'"), array('&', '<', '>', '"', '''), $text); } function echo_sitemap_url($loc, $priority, $freq) { $loc_xml = isset($_SERVER['HTTP_HOST']) ? xmlentities("http://{$_SERVER['HTTP_HOST']}/{$loc}") : xmlentities("http://www.boost.org/{$loc}"); echo <<<EOL <url> <loc>{$loc_xml}</loc> <priority>{$priority}</priority> <changefreq>{$freq}</changefreq> </url> EOL; } // Library list echo_sitemap_url("doc/libs/", '1.0', 'daily'); // Library 'home pages' $libs = BoostLibraries::load(); // TODO: Include hidden libraries? Or not? foreach ($libs->get_for_version(BoostVersion::current()) as $lib) { echo_sitemap_url("doc/libs/release/{$lib['documentation']}", '1.0', 'daily'); } ?> </urlset>
<?php require_once __DIR__ . '/../common/code/bootstrap.php'; if (isset($_GET['version'])) { try { $version = BoostVersion::from($_GET['version']); } catch (BoostVersion_Exception $e) { header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); echo json_encode(array('error' => $e->getMessage())); exit(0); } } else { $version = BoostVersion::current(); } // TODO: This is a bit awkard, should probably have an alternative // to 'get_for_version' which returns a BoostLibraries instance // rather than an array. // TODO: Include hidden libraries. $version_libs = array_map(function ($lib) { return new BoostLibrary($lib); }, BoostLibraries::load()->get_for_version($version)); header('Content-type: application/json'); echo BoostLibrary::get_libraries_json($version_libs); echo $version_libs->to_json();