Create your own API site
Introduction
These instructions are for creating a site similar to Drupal API using the API Module.
How to create an API site
Quick setup
The module has a demo folder containing a readme file and a script that you can run in isolation and the script will do everything for you. See the readme file inside the demo folder for a one-line command.
Step by step
You can also run the steps one by one to better understand how the module works:
Setup the site
- Begin with a Drupal site that is compatible with a Drupal 10+ version of the API module.
- Add the API project with a command similar to this. Check the API module page for available versions.
composer require drupal/api - Add batch UI module. This is optional.
composer require drupal/queue_ui - Install the API module and the Queue UI module.
Setup the module and projects
Step-by-step version
Now, get the code to parse and display. The default location the API module will look for is sites/default/files/api_git_repositories. In this example, Drupal core is the project and the current working directory in the Drupal root. Adjust the command as needed for your project.
git clone --branch 11.x http://git.drupal.org/project/drupal.git ./sites/default/files/api_git_repositories/drupal
Once the project files are in place
Go to admin/config/development/api/projectand add a new project.Go to admin/config/development/api/branchand add a new branch.- Process the queue to index the branch, using either cron
admin/config/system/cronor the Queue UI- Got to admin/config/system/queue-ui,
- Select 'Batch process' action.
- Select 'Parse Queue Worker'
- Save changes
- Got to admin/config/system/queue-ui,
- Go to your new api documentation at path:
api. The content should resemble the content at Drupal API.
Quick version
All the above setup steps can also be done via the QuickWizard UI (and drush command) where you only need to put the "https" URL of the repo and the branches to parse (optional, defaults to all), and the form (or command) will do everything for you automatically.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion