12 Documenting an API

 

This chapter covers

  • Reference documentation
  • User guides
  • Implementer specifications
  • Change logs

In previous chapters, you discovered that designing APIs requires more than just designing usable APIs doing the job. Indeed, we have to take care of the whole context surrounding the API when designing it. But this context goes beyond that of the API itself—its interface contract, its implementation, and how and by whom it is used. API designers have to participate in various aspects of API projects, and a very important one is documentation.

The best designs of even the simplest things need documentation. As shown in figure 12.1, everyday objects can come with various types of documentation to help users understand how to use them, as well as to help the people in charge of building those objects to actually build them.

Figure 12.1 Different types of documentation

12-01.png

Page 1 of the Alarm Clock User Manual shows an annotated figure of the alarm clock. Thanks to that, users know what the components of the user interface are and their roles, even if the device’s user-friendly design makes this fairly obvious. But this first page of documentation alone is not enough to operate the alarm clock. That’s why page 2 shows its various functions, such as how to set the alarm by using the Set Alarm and plus and minus buttons.

12.1 Creating reference documentation

12.1.1 Documenting data models

12.1.2 Documenting goals

12.1.3 Documenting security

12.1.4 Providing an overview of the API

12.1.5 Generating documentation from the implementation: pros and cons

12.2 Creating a user guide

12.2.1 Documenting use cases

12.2.2 Documenting security

12.2.3 Providing an overview of common behaviors and principles

12.2.4 Thinking beyond static documentation

12.3 Providing adequate information to implementers

12.4 Documenting evolutions and retirement

Summary