This markdown file was generated using `docs/regenerate.php`. Any edits to it will likely be lost.'; return Str\join($lines, "\n"); } /** * Return documentation for the given namespace. */ function get_namespace_documentation(string $namespace): string { $lines = []; $lines[] = Str\format('### `%s`', $namespace); $lines[] = ''; /** * @param array{ * 'constants' => list, * 'functions' => list, * 'interface' => list, * 'classes' => list, * 'traits' => list, * } $symbols * @param 'constants'|'functions'|'interfaces'|'classes'|'traits' $type * * @return list */ $generator = static function ( string $directory, array $symbols, string $type ): array { $lines = []; if (Iter\count($symbols[$type]) > 0) { $lines[] = Str\format('#### `%s`', Str\uppercase($type)); $lines[] = ''; foreach ($symbols[$type] as $function) { $short_name = Str\after_last($function, '\\'); if ('constants' === $type) { $url = Str\format('%s%s%s.php', $directory, Filesystem\SEPARATOR, 'constants'); } else { $url = Str\format('%s%s%s.php', $directory, Filesystem\SEPARATOR, $short_name); } $deprecation_notice = ''; if (Str\contains(Filesystem\read_file(Filesystem\canonicalize(__DIR__ . '/' . $url)), '@deprecated')) { $deprecation_notice .= ' ( deprecated )'; } $lines[] = Str\format('- [%s](%s)%s', $short_name, $url, $deprecation_notice); } $lines[] = ''; } return $lines; }; $directory = './../src/' . Str\replace($namespace, '\\', '/'); $symbols = get_direct_namespace_symbols($namespace); return Str\join(Vec\concat( $lines, $generator($directory, $symbols, 'constants'), $generator($directory, $symbols, 'functions'), $generator($directory, $symbols, 'interfaces'), $generator($directory, $symbols, 'classes'), $generator($directory, $symbols, 'traits'), [''] ), "\n"); } /** * Return a shape contains all direct symbols in the given namespace. * * @return array{ * 'constants' => list, * 'functions' => list, * 'interface' => list, * 'classes' => list, * 'traits' => list, * } */ function get_direct_namespace_symbols(string $namespace): array { /** @var (callable(list): list) $filter */ $filter = static fn(array $list) => Vec\filter( $list, static function (string $symbol) use ($namespace): bool { if (!Str\starts_with_ci($symbol, $namespace)) { return false; } $short_symbol_name = Type\string()->assert(Str\after_ci($symbol, $namespace . '\\')); return !Str\contains($short_symbol_name, '\\'); } ); return [ 'constants' => $filter(Loader::CONSTANTS), 'functions' => $filter(Loader::FUNCTIONS), 'interfaces' => $filter(Loader::INTERFACES), 'classes' => $filter(Loader::CLASSES), 'traits' => $filter(Loader::TRAITS), ]; } /** * @return list */ function get_all_namespaces(): array { return [ 'Psl', 'Psl\Arr', 'Psl\Collection', 'Psl\DataStructure', 'Psl\Dict', 'Psl\Encoding\Base64', 'Psl\Encoding\Hex', 'Psl\Env', 'Psl\Filesystem', 'Psl\Fun', 'Psl\Hash', 'Psl\Html', 'Psl\Iter', 'Psl\Json', 'Psl\Math', 'Psl\Observer', 'Psl\Password', 'Psl\PseudoRandom', 'Psl\Regex', 'Psl\Result', 'Psl\SecureRandom', 'Psl\Shell', 'Psl\Str', 'Psl\Str\Byte', 'Psl\Str\Grapheme', 'Psl\Type', 'Psl\Vec', ]; }