Skip to content

Commit

Permalink
Merge pull request #289 from wp-cli/37-rm-command-docs
Browse files Browse the repository at this point in the history
Remove command docs
  • Loading branch information
schlessera authored May 18, 2017
2 parents 7189377 + 5e798f3 commit 1c26a0d
Show file tree
Hide file tree
Showing 291 changed files with 0 additions and 13,290 deletions.
92 changes: 0 additions & 92 deletions command.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
function generate() {
generate_homepage();
generate_commands();
}
WP_CLI::add_command( 'website generate', 'WP_CLI_Org\generate' );

Expand Down Expand Up @@ -56,91 +55,6 @@ function generate_homepage() {
}
WP_CLI::add_command( 'website generate-homepage', '\WP_CLI_Org\generate_homepage' );

/**
* Generate the /commands/ page.
*
* @when before_wp_load
*/
function generate_commands() {
$wp = invoke_wp_cli( 'wp --skip-packages cli cmd-dump' );

foreach( $wp['subcommands'] as $k => $cmd ) {
if ( in_array( $cmd['name'], array( 'website', 'api-dump' ) ) ) {
unset( $wp['subcommands'][ $k ] );
}
}
$wp['subcommands'] = array_values( $wp['subcommands'] );

// generate main page
file_put_contents( '_includes/cmd-list.html', render( 'cmd-list.mustache', $wp ) );
WP_CLI::log( 'Generated /commands/' );

foreach ( $wp['subcommands'] as $cmd ) {
gen_cmd_pages( $cmd );
}
WP_CLI::success( 'Generated all command pages.' );
}
WP_CLI::add_command( 'website generate-commands', '\WP_CLI_Org\generate_commands' );

function gen_cmd_pages( $cmd, $parent = array() ) {
$parent[] = $cmd['name'];

$binding = $cmd;
$binding['synopsis'] = implode( ' ', $parent );
$binding['path'] = implode( '/', $parent );
$path = '/commands/';
$binding['breadcrumbs'] = '[Commands](' . $path . ')';
foreach( $parent as $i => $p ) {
$path .= $p . '/';
if ( $i < ( count( $parent ) - 1 ) ) {
$binding['breadcrumbs'] .= " &raquo; [{$p}]({$path})";
} else {
$binding['breadcrumbs'] .= " &raquo; {$p}";
}
}
$binding['has-subcommands'] = isset( $cmd['subcommands'] ) ? array(true) : false;

if ( $cmd['longdesc'] ) {
$docs = $cmd['longdesc'];
$docs = htmlspecialchars( $docs, ENT_COMPAT, 'UTF-8' );

// decrease header level
$docs = preg_replace( '/^## /m', '### ', $docs );

// escape `--` so that it doesn't get converted into `&mdash;`
$docs = preg_replace( '/^(\[?)--/m', '\1\--', $docs );
$docs = preg_replace( '/^\s\s--/m', ' \1\--', $docs );

// hack to prevent double encoding in code blocks
$docs = preg_replace( '/ &lt; /', ' < ', $docs );
$docs = preg_replace( '/ &gt; /', ' > ', $docs );
$docs = preg_replace( '/ &lt;&lt;/', ' <<', $docs );
$docs = preg_replace( '/&quot;/', '"', $docs );
$docs = preg_replace( '/wp&gt; /', 'wp> ', $docs );
$docs = preg_replace( '/=&gt;/', '=>', $docs );

// Strip global parameters -> added in footer
$docs = preg_replace( '/#?## GLOBAL PARAMETERS.+/s', '', $docs );

$binding['docs'] = $docs;
$binding['github_issues_link'] = 'https://github.com/wp-cli/wp-cli/issues?q=is%3Aopen+label%3A' . urlencode( 'command:' . str_replace( ' ', '-', $binding['synopsis'] ) ) . '+sort%3Aupdated-desc';
}

$path = __DIR__ . "/commands/" . $binding['path'];
if ( !is_dir( $path ) ) {
mkdir( $path );
}
file_put_contents( "$path/index.md", render( 'subcmd-list.mustache', $binding ) );
WP_CLI::log( 'Generated /commands/' . $binding['path'] . '/' );

if ( !isset( $cmd['subcommands'] ) )
return;

foreach ( $cmd['subcommands'] as $subcmd ) {
gen_cmd_pages( $subcmd, $parent );
}
}

function invoke_wp_cli( $cmd ) {
ob_start();
system( "WP_CLI_CONFIG_PATH=/dev/null $cmd", $return_code );
Expand All @@ -153,9 +67,3 @@ function invoke_wp_cli( $cmd ) {

return json_decode( $json, true );
}

function render( $path, $binding ) {
$m = new Mustache_Engine;
$template = file_get_contents( __DIR__ . "/_templates/$path" );
return $m->render( $template, $binding );
}
5 changes: 0 additions & 5 deletions commands/blog/create/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions commands/blog/delete/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions commands/blog/empty/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions commands/blog/index.md

This file was deleted.

45 changes: 0 additions & 45 deletions commands/cache/add/index.md

This file was deleted.

41 changes: 0 additions & 41 deletions commands/cache/decr/index.md

This file was deleted.

35 changes: 0 additions & 35 deletions commands/cache/delete/index.md

This file was deleted.

29 changes: 0 additions & 29 deletions commands/cache/flush/index.md

This file was deleted.

35 changes: 0 additions & 35 deletions commands/cache/get/index.md

This file was deleted.

41 changes: 0 additions & 41 deletions commands/cache/incr/index.md

This file was deleted.

Loading

0 comments on commit 1c26a0d

Please sign in to comment.