Skip to content

Instantly share code, notes, and snippets.

@zdne
Created October 13, 2015 14:15
Show Gist options
  • Save zdne/137396a1c2d45f75b306 to your computer and use it in GitHub Desktop.
Save zdne/137396a1c2d45f75b306 to your computer and use it in GitHub Desktop.

Working with multiple blueprint files

This document describes 4 different solutions to work APIs that consist of multiple blueprint files. Every of this solution work with all of the Apiary.io features with the exception of editing in the Apiary.io online editor. To edit a blueprint you have to do it outside of Apiary as Apiary editor does not support working with multiple files.

In other words if you are using one of the solutions below avoid editing the blueprint in Apiary.

1. Hercule

Hercule is a CLI tool written in Node.js – available as an NPM package. It uses markdown referencing and linking syntax to transclude other files into a blueprint file. This solution is universal and would work with any Markdown files not just API Blueprint.

The major benefit – unlike any other solutions here – is also that the references are rendered as HTML links in any Markdown editor so the result is HTML that can be browsed!

The syntax used in Hercule is the closest to the offical API Blueprint referencing syntax as proposed at apiaryio/api-blueprint#8 and apiaryio/api-blueprint#20.

Example syntax:

# Gist Fox API

# Group Gist

:[Gist](blueprint/gist.apib)

:[Gists](blueprint/gists.apib)

Source:

https://github.com/jamesramsay/hercule

2. Aglio

Aglio is very popular static-site renderer for API Blueprint. It came with its very own transclusion syntax utilizing HTML comments. As a downside, if you render this as a plain Markdown (e.g. on GitHub) the references will disapear.

Example syntax:

# Gist Fox API

# Group Gist

<!-- include(blueprint/gist.apib) -->

<!-- include(blueprint/gists.apib) -->

Source:

https://github.com/danielgtaylor/aglio

Example:

https://github.com/the-grid/apidocs/

3. Grunt task

A node.js grunt task that concatenates files into the apiary.apib . It can also push – publish – the blueprint into Apiary.

Source:

https://github.com/dac09/grunt-apiary-blueprint

4. Apiary manifest

Alpha-stage tool developed by Apiary. Working only with Apiary GitHub integration. Works similarly to Grunt task however you have to explicitly enumerate files to be concatenate in the apiary.manifest file. This manifest file must be in the root of your repository. It is recommended to NOT use apiary.apib file with this solution.

Syntax (apiary.manifest) :

api_intro.apib
blueprint/gist.apib
blueprint/gists.apib

Example:

https://github.com/zdne/apiary-manifest


Roundup

Personally I endorse the Hercule and it is syntax mainly because that solution works event without the Hercule tool. The Hercule syntax is also the closest to the one proposed for API Blueprint.

The most popular one at this moment is probably the syntax introduced in Aglio.

Concatenation solutions (Grunt task and Apiary manifest) feels simple but very limiting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment