All Projects → humanmade → Restsplain

humanmade / Restsplain

Licence: gpl-3.0
WordPress REST API documentation generator

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Restsplain

Live Composer Page Builder
Free page builder plugin for WordPress http://livecomposerplugin.com
Stars: ✭ 143 (+13.49%)
Mutual labels:  wordpress-api, wordpress, wordpress-plugin
Ultimate Fields
The plugin for custom fields in WordPress
Stars: ✭ 39 (-69.05%)
Mutual labels:  wordpress-api, wordpress, wordpress-plugin
Create React Wptheme
Create modern, React-enabled WordPress themes with a single command.
Stars: ✭ 252 (+100%)
Mutual labels:  wordpress-api, create-react-app, wordpress
Better Rest Endpoints
A WordPress plugin that serves up slimmer WP Rest API endpoints.
Stars: ✭ 56 (-55.56%)
Mutual labels:  wordpress-api, wordpress, wordpress-plugin
Intervention
WordPress plugin to configure wp-admin and application state using a single config file.
Stars: ✭ 481 (+281.75%)
Mutual labels:  wordpress-api, wordpress, wordpress-plugin
Headless Wp
A demo repo for Headless WordPress
Stars: ✭ 89 (-29.37%)
Mutual labels:  wordpress-api, create-react-app, wordpress
S3 Uploads
The WordPress Plugin to Store Uploads on Amazon S3
Stars: ✭ 1,573 (+1148.41%)
Mutual labels:  wordpress, wordpress-plugin
Wp Cache Remember
Helper for the WordPress object cache and transients.
Stars: ✭ 111 (-11.9%)
Mutual labels:  wordpress, wordpress-plugin
Acf Codifier
A wrapper class to help write more readable ACF field declarations.
Stars: ✭ 114 (-9.52%)
Mutual labels:  wordpress, wordpress-plugin
Regenerate Thumbnails
WordPress plugin for regenerating thumbnails of uploaded images. Over 1 million active users and counting.
Stars: ✭ 115 (-8.73%)
Mutual labels:  wordpress, wordpress-plugin
Wp Postviews
Enables you to display how many times a post/page had been viewed.
Stars: ✭ 107 (-15.08%)
Mutual labels:  wordpress, wordpress-plugin
Piklist
The most powerful framework available for WordPress.
Stars: ✭ 114 (-9.52%)
Mutual labels:  wordpress, wordpress-plugin
Antispam Bee
„... another popular solution to fight spam is Antispam Bee“ – Matt Mullenweg, Q&A WordCamp Europe 2014
Stars: ✭ 124 (-1.59%)
Mutual labels:  wordpress, wordpress-plugin
Wp Pagenavi
Adds a more advanced paging navigation interface to your WordPress blog.
Stars: ✭ 121 (-3.97%)
Mutual labels:  wordpress, wordpress-plugin
Frontpress
⚡️ A full front-end AngularJS template for WordPress Rest API.
Stars: ✭ 109 (-13.49%)
Mutual labels:  wordpress-api, wordpress
Subtitles
Add subtitles into your WordPress posts, pages, custom post types, and themes. No coding required. Simply activate Subtitles and you're ready to go.
Stars: ✭ 113 (-10.32%)
Mutual labels:  wordpress, wordpress-plugin
Nextjs Wordpress Starter
WebDevStudios Next.js WordPress Starter
Stars: ✭ 104 (-17.46%)
Mutual labels:  wordpress-api, wordpress
Wp Postratings
Adds an AJAX rating system for your WordPress blog's post/page.
Stars: ✭ 115 (-8.73%)
Mutual labels:  wordpress, wordpress-plugin
Wp Graphql Yoast Seo
This is an extension to the WPGraphQL plugin for Yoast SEO
Stars: ✭ 120 (-4.76%)
Mutual labels:  wordpress, wordpress-plugin
Wordpress Activitypub
ActivityPub for WordPress
Stars: ✭ 118 (-6.35%)
Mutual labels:  wordpress, wordpress-plugin

Restsplain

Super fast WordPress REST API docs that update with your site.
A Human Made project. Maintained by @roborourke.

The WordPress REST API provides much of it's own documentation via it's schema. This plugin contains a React app that consumes the schema data to generate a blazing fast documentation site.

  1. Add and edit high level documentation pages
  2. Automatic discovery and display of all custom endpoints
  3. Make API requests direct from the documentation!

Restsplain running on TwentySeventeen

Installation

Upload the plugin to your plugins directory and activate it.

You'll need to refresh your permalinks to use the built in URL by visiting the permalinks settings page in the admin.

Once you've done that browse to http://your-site.com/api-docs/ and you're done!

Configuration

Hopefully you won't need to do much configuration with Restsplain however there are a number of filters you can use to change it's behaviour.

Default URL

The docs will by default show at /api-docs/ however you can modify this using the filter:

<?php
add_filter( 'restsplain_docs_base', function() {
	return '/api/docs';
} );

Default content

In the admin you'll see a new post type called "API Docs". Default pages will be created for you if you don't add any before visiting the docs however you can edit these and add to them or remove them afterwards.

The top level pages are:

  1. Global Parameters
  2. Linking and Embedding
  3. Errors

In addition a page for each default authentication type and each route will be added.

When you create a page for a route you should make the title exactly the same as the route key in the schema eg. /wp/v2/posts/(?P<id>[\d]+).

If the title does not match then the page is treated as top level documentation and will appear at the top of the menu.

Adding default pages

Developers can add support for Restsplain in one of 2 ways:

  1. Filter the schema output with the rest_index hook and add a description and optional excerpt key/value to each route object.
  2. Add a file with the namespace Restsplain and call add_default_page( $slug, $page )
<?php
namespace Restsplain;

// Accepts just a string
add_default_page( '/wp/v2/users', __( 'Fetch or create Users.' ) );

// Or an array with keys title, excerpt and content
add_default_page( 'oauth1', array(
	'title'   => __( 'Oauth 1.0a' ),
	'excerpt' => __( 'Endpoints for authenticating requests with Oauth 1.0a' ),
	'content' => '<p>...</p>', 
) );

Pages will be created in the admin that can then be edited.

Theming

By default Restsplain is written to use as much of your site's existing styles as possible so your fonts and typography should all be respected. In addition if your theme supports a custom logo it will be displayed in the header.

The standard calls to wp_head() and wp_footer() are present in the template so adding your own CSS is simple. Everything is styled under the .restsplain namespace.

NOTE: You will more than likely have to add some styles if your theme does not have rules for tables are global element rules for example.

highlight.js

You may wish to change the code highlighter to a different theme to suit your design.

Code highlighting is done using highlight.js so you can provide the name of any one of its 77 styles. You can find them at https://highlightjs.org/static/demo/

<?php
add_filter( 'restsplain_config', function( $config ) {
	$config['codeTheme'] = 'docco';
	return $config;
} );

Logo

Your custom logo will be used by default if your theme supports it and you have one uploaded. Otherwise you can use a filter to change it to some other image URL.

<?php
add_filter( 'restsplain_config', function( $config ) {
	$config['logo'] = 'http://www.fillmurray.com/g/200/200';
	return $config;
} );

Localisation

The plugin is translation ready including the React component. If you'd like to provide a translation let us know!

Note to developers

The docs generated by an automated tool such as this will only be as good as the docs you build into your API endpoint definitions. Learn about and add proper schemas to your plugin or theme endpoints:

https://developer.wordpress.org/rest-api/extending-the-rest-api/schema/

There will be bugs, there will

If you're interested in contributing to and improving Restsplain (and it will need it!) there are a few things you need to know besides React:

Running the app locally

Restsplain is built using create-react-app which is a great way to get up and running quickly with React.

The app itself is in the app folder of the plugin.

Clone the repo and grab everything you need to work on the React app.

git clone [email protected]:humanmade/Restsplain.git
cd Restsplain/app
npm install # or yarn
npm start # or yarn start

Styling tips

The built in CSS is intentionally low level and layout focused. Ideally the plugin should look as native to the site it is running on as possible with minimal input required from the site owner.

Styling is done using Sass (compiled separately to the final bundle, see the package.json npm scripts for details) which is compiled and the resulting CSS then imported via the JavaScript. Webpack takes care of processing this and generating the final file.

Debug mode

Add define( 'RESTSPLAIN_DEBUG', true ); to your config file to make the plugin use the development files served from http://localhost:3000

NOTE: Currently the hotloading doesn't work in the WordPress context so if you know how to fix it create a pull request!

License

Restsplain is licensed under the GPLv3 or later.

Credits

Created by Human Made for easing the pain of keeping up to date documentation for our new API driven WordPress world.

Written and maintained by Robert O'Rourke

Interested in joining in on the fun? Join us, and become human!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].