Skip to content

Commit e8a420b

Browse files
committed
generate help page for each command
1 parent ce61eed commit e8a420b

145 files changed

Lines changed: 3150 additions & 33 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Phakefile.php

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,46 @@ function generate_synopsis( $command, $path = '' ) {
3939
generate_synopsis( invoke_wp_cli( 'wp --cmd-dump', $app ) );
4040
});
4141

42+
function gen_cmd_pages( $wp_cli_path, $cmd, $parent = array() ) {
43+
$parent[] = $cmd['name'];
44+
45+
$binding = $cmd;
46+
$binding['synopsis'] = implode( ' ', $parent );
47+
$binding['path'] = implode( '/', $parent );
48+
$binding['has-subcommands'] = isset( $cmd['subcommands'] ) ? array(true) : false;
49+
50+
$docs_path = $wp_cli_path . '/man-src/' . implode( '-', $parent ) . '.txt';
51+
if ( is_readable( $docs_path ) ) {
52+
$docs = file_get_contents( $docs_path );
53+
$docs = preg_replace( '/^## /m', '### ', $docs );
54+
$docs = preg_replace( '/\n\* `(.+)`([^\n]*):\n\n/', "\n\t\\1\\2\n\t\t", $docs );
55+
$binding['docs'] = $docs;
56+
}
57+
58+
$path = __DIR__ . "/commands/" . $binding['path'];
59+
mkdir( $path );
60+
file_put_contents( "$path/index.md", render( 'subcmd-list.mustache', $binding ) );
61+
62+
if ( !isset( $cmd['subcommands'] ) )
63+
return;
64+
65+
foreach ( $cmd['subcommands'] as $subcmd ) {
66+
gen_cmd_pages( $wp_cli_path, $subcmd, $parent );
67+
}
68+
}
69+
4270
desc( 'Update the /commands/ page.' );
4371
task( 'cmd-list', function( $app ) {
4472
$wp = invoke_wp_cli( 'wp --cmd-dump', $app );
45-
$wp['version'] = $app['version'];
4673

74+
// generate main page
4775
file_put_contents( '_includes/cmd-list.html', render( 'cmd-list.mustache', $wp ) );
76+
77+
system( sprintf( 'rm -rf %s/commands/*/', escapeshellarg( __DIR__ ) ) );
78+
79+
foreach ( $wp['subcommands'] as $cmd ) {
80+
gen_cmd_pages( $app['path'], $cmd );
81+
}
4882
});
4983

5084
desc( 'Update the /config/ page.' );

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
3. Build:
88

99
```bash
10-
vendor/bin/phake path=/path/to/wp/install version=v0.10.2
10+
vendor/bin/phake path=/path/to/wp-cli-dir
1111
```
1212

1313
### Preview locally

_includes/cmd-list.html

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,100 @@
11
<tr>
2-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/blog.php">blog</a></td>
2+
<td><a href="/commands/blog/">blog</a></td>
33
<td>Manage blogs in a multisite install.</td>
44
</tr>
55
<tr>
6-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/cache.php">cache</a></td>
6+
<td><a href="/commands/cache/">cache</a></td>
77
<td>Manage the object cache.</td>
88
</tr>
99
<tr>
10-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/cap.php">cap</a></td>
10+
<td><a href="/commands/cap/">cap</a></td>
1111
<td>Manage user capabilities.</td>
1212
</tr>
1313
<tr>
14-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/comment.php">comment</a></td>
14+
<td><a href="/commands/comment/">comment</a></td>
1515
<td>Manage comments.</td>
1616
</tr>
1717
<tr>
18-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/core.php">core</a></td>
18+
<td><a href="/commands/core/">core</a></td>
1919
<td>Download, install, update and otherwise manage WordPress proper.</td>
2020
</tr>
2121
<tr>
22-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/db.php">db</a></td>
22+
<td><a href="/commands/db/">db</a></td>
2323
<td>Perform basic database operations.</td>
2424
</tr>
2525
<tr>
26-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/eval.php">eval</a></td>
26+
<td><a href="/commands/eval/">eval</a></td>
2727
<td>Execute arbitrary PHP code after loading WordPress.</td>
2828
</tr>
2929
<tr>
30-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/eval-file.php">eval-file</a></td>
30+
<td><a href="/commands/eval-file/">eval-file</a></td>
3131
<td>Load and execute a PHP file after loading WordPress.</td>
3232
</tr>
3333
<tr>
34-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/export.php">export</a></td>
34+
<td><a href="/commands/export/">export</a></td>
3535
<td>Export content to a WXR file.</td>
3636
</tr>
3737
<tr>
38-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/help.php">help</a></td>
38+
<td><a href="/commands/help/">help</a></td>
3939
<td>Get help on a certain topic.</td>
4040
</tr>
4141
<tr>
42-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/media.php">media</a></td>
42+
<td><a href="/commands/media/">media</a></td>
4343
<td>Control the media library and its attachments.</td>
4444
</tr>
4545
<tr>
46-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/option.php">option</a></td>
46+
<td><a href="/commands/option/">option</a></td>
4747
<td>Manage WordPress options.</td>
4848
</tr>
4949
<tr>
50-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/plugin.php">plugin</a></td>
50+
<td><a href="/commands/plugin/">plugin</a></td>
5151
<td>Manage plugins.</td>
5252
</tr>
5353
<tr>
54-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/post.php">post</a></td>
54+
<td><a href="/commands/post/">post</a></td>
5555
<td>Manage posts.</td>
5656
</tr>
5757
<tr>
58-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/post-meta.php">post-meta</a></td>
58+
<td><a href="/commands/post-meta/">post-meta</a></td>
5959
<td>Manage post custom fields.</td>
6060
</tr>
6161
<tr>
62-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/rewrite.php">rewrite</a></td>
62+
<td><a href="/commands/rewrite/">rewrite</a></td>
6363
<td>Manage rewrite rules.</td>
6464
</tr>
6565
<tr>
66-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/role.php">role</a></td>
66+
<td><a href="/commands/role/">role</a></td>
6767
<td>Manage user roles.</td>
6868
</tr>
6969
<tr>
70-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/scaffold.php">scaffold</a></td>
70+
<td><a href="/commands/scaffold/">scaffold</a></td>
7171
<td>Generate code for post types, taxonomies, etc.</td>
7272
</tr>
7373
<tr>
74-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/search-replace.php">search-replace</a></td>
74+
<td><a href="/commands/search-replace/">search-replace</a></td>
7575
<td>Search/replace strings in the database.</td>
7676
</tr>
7777
<tr>
78-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/shell.php">shell</a></td>
78+
<td><a href="/commands/shell/">shell</a></td>
7979
<td>Interactive PHP console.</td>
8080
</tr>
8181
<tr>
82-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/term.php">term</a></td>
82+
<td><a href="/commands/term/">term</a></td>
8383
<td>Manage terms.</td>
8484
</tr>
8585
<tr>
86-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/theme.php">theme</a></td>
86+
<td><a href="/commands/theme/">theme</a></td>
8787
<td>Manage themes.</td>
8888
</tr>
8989
<tr>
90-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/transient.php">transient</a></td>
90+
<td><a href="/commands/transient/">transient</a></td>
9191
<td>Manage WordPress transients.</td>
9292
</tr>
9393
<tr>
94-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/user.php">user</a></td>
94+
<td><a href="/commands/user/">user</a></td>
9595
<td>Manage users.</td>
9696
</tr>
9797
<tr>
98-
<td><a href="https://github.com/wp-cli/wp-cli/blob/v0.10.2/php/commands/user-meta.php">user-meta</a></td>
98+
<td><a href="/commands/user-meta/">user-meta</a></td>
9999
<td>Manage user custom fields.</td>
100100
</tr>

_templates/cmd-list.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{#subcommands}}
22
<tr>
3-
<td><a href="https://github.com/wp-cli/wp-cli/blob/{{version}}/php/commands/{{name}}.php">{{name}}</a></td>
3+
<td><a href="/commands/{{name}}/">{{name}}</a></td>
44
<td>{{description}}</td>
55
</tr>
66
{{/subcommands}}

_templates/subcmd-list.mustache

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
layout: default
3+
title: 'wp {{synopsis}}'
4+
---
5+
6+
`wp {{synopsis}}` - {{description}}
7+
8+
{{{docs}}}
9+
10+
{{#has-subcommands}}
11+
### SUBCOMMANDS
12+
13+
<table>
14+
<thead>
15+
<tr>
16+
<th>Name</th>
17+
<th>Description</th>
18+
</tr>
19+
</thead>
20+
<tbody>
21+
{{#subcommands}}
22+
<tr>
23+
<td><a href="/commands/{{path}}/{{name}}">{{name}}</a></td>
24+
<td>{{description}}</td>
25+
</tr>
26+
{{/subcommands}}
27+
</tbody>
28+
</table>
29+
{{/has-subcommands}}

assets/css/stylesheet.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,23 +188,23 @@ pre code {
188188
background-color: inherit;
189189
}
190190

191+
h3 + table {
192+
margin-top: 10px;
193+
}
194+
191195
table {
192196
width: 100%;
193197
margin: 0 0 20px 0;
194198
}
195199

196200
th, td {
197201
vertical-align: top;
202+
padding: 5px 20px 5px 0;
198203
}
199204

200205
th {
201206
text-align: left;
202207
border-bottom: 1px dashed #b5e853;
203-
padding: 5px 10px;
204-
}
205-
206-
td {
207-
padding: 5px 10px;
208208
}
209209

210210
hr {

commands/blog/create/index.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
layout: default
3+
title: 'wp blog create'
4+
---
5+
6+
`wp blog create` - Create a blog in a multisite install.
7+
8+
### OPTIONS
9+
10+
--slug=<slug>
11+
Path for the new blog. Subdomain on subdomain installs, directory on subdirectory installs.
12+
13+
--title=<title&gt;
14+
Title of the new blog. Default: prettified slug.
15+
16+
--email=<email>
17+
Email for Admin user. User will be created if none exists. Assignement to Super Admin if not included.
18+
19+
--site_id=<site-id>
20+
Site (network) to associate new blog with. Defaults to current site (typically 1).
21+
22+
--private
23+
If set, the new blog will be non-public (not indexed)
24+
25+
--porcelain
26+
If set, only the blog id will be output on success.
27+
28+

commands/blog/delete/index.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
layout: default
3+
title: 'wp blog delete'
4+
---
5+
6+
`wp blog delete` - Delete a blog in a multisite install.
7+
8+
### OPTIONS
9+
10+
<blog-id>
11+
The id of the blog to delete. If not provided, you must set the --slug parameter.
12+
13+
--slug=<slug>
14+
Path of the blog to be deleted. Subdomain on subdomain installs, directory on subdirectory installs.
15+
16+
--yes
17+
Answer yes to the confirmation message.
18+
19+
--keep-tables
20+
Delete the blog from the list, but don't drop it's tables.
21+
22+

commands/blog/empty/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
layout: default
3+
title: 'wp blog empty'
4+
---
5+
6+
`wp blog empty` - Empty a blog of its content.
7+
8+
### EXAMPLES
9+
10+
wp blog empty
11+

commands/blog/index.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
layout: default
3+
title: 'wp blog'
4+
---
5+
6+
`wp blog` - Manage blogs in a multisite install.
7+
8+
9+
10+
### SUBCOMMANDS
11+
12+
<table>
13+
<thead>
14+
<tr>
15+
<th>Name</th>
16+
<th>Description</th>
17+
</tr>
18+
</thead>
19+
<tbody>
20+
<tr>
21+
<td><a href="/commands/blog/create">create</a></td>
22+
<td>Create a blog in a multisite install.</td>
23+
</tr>
24+
<tr>
25+
<td><a href="/commands/blog/delete">delete</a></td>
26+
<td>Delete a blog in a multisite install.</td>
27+
</tr>
28+
<tr>
29+
<td><a href="/commands/blog/empty">empty</a></td>
30+
<td>Empty a blog of its content.</td>
31+
</tr>
32+
</tbody>
33+
</table>

0 commit comments

Comments
 (0)