Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8da3ed2

Browse files
committed
Add alt text to all images in the "ExDoc cheatsheets" blog post
1 parent 4502a86 commit 8da3ed2

File tree

1 file changed

+56
-51
lines changed

1 file changed

+56
-51
lines changed

_posts/2022-12-22-cheatsheets-and-8-other-features-in-exdoc-that-improve-the-developer-experience.markdown

Lines changed: 56 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,69 +10,66 @@ ExDoc has a cool new feature, [cheatsheets](https://hexdocs.pm/ex_doc/cheatsheet
1010

1111
In this blog post, we'll explain what that new feature is and the motivation behind it. We'll also take the opportunity to highlight other ExDoc features that show how it has been evolving to make the documentation experience in Elixir better and better.
1212

13-
## What are ExDoc Cheatsheets and how they improve the documentation experience
14-
ExDoc's Cheatsheets are Markdown files with the `.cheatmd` extension. You can see [an example](https://hexdocs.pm/ecto/crud.html) of how the Ecto project is using them.
13+
## What are ExDoc cheatsheets and how they improve the documentation experience
1514

16-
Writing and reading cheatsheets is not exactly new to developers. What ExDoc brings to the table is the possibility of integrating cheatsheets alongside the rest of the documentation of an Elixir project, instead of hosting it in a different place.
15+
ExDoc's cheatsheets are Markdown files with the `.cheatmd` extension. You can see [an example](https://hexdocs.pm/ecto/crud.html) of how the Ecto project is using them.
1716

18-
Developers need different kinds of docs at different times. When one is learning about a new library, a guide format is proper. When one needs to know if a library can solve a specific problem, an API reference can be more appropriate. When someone wants to remember a couple of functions they already used from that library, a cheatsheet could be more practical.
17+
Writing and reading cheatsheets is not exactly new to developers. What ExDoc brings to the table is the possibility of integrating cheatsheets alongside the rest of the documentation of an Elixir project, instead of hosting them in a different place.
1918

20-
Imagine if you had to go to a different place for every type of documentation you're looking for. That would make a very fragmented experience, not only for readers of documentation but also for writers.
19+
Developers need different kinds of documentation at different times. When one is learning about a new library, a guide format is proper. When one needs to know if a library can solve a specific problem, an API reference can be more appropriate. When someone wants to remember a couple of functions they already used from that library, a cheatsheet could be more practical.
2120

22-
ExDoc Cheatsheets represent one step further in the direction of making documentation in Elixir an even more comprehensive and integrated experience.
21+
Imagine if you had to go to a different place for every type of documentation you're looking for. That would make a very fragmented experience, not only for readers of documentation but also for writers.
2322

24-
ExDoc Cheatsheets are inspired by [devhints.io](https://devhints.io) from [Rico Sta. Cruz](https://twitter.com/rstacruz), and were contributed by [Paulo Valim](https://twitter.com/paulovalim) and [Yordis Prieto](https://twitter.com/alchemist_ubi).
23+
ExDoc cheatsheets represent one step further in the direction of making documentation in Elixir an even more comprehensive and integrated experience.
2524

25+
ExDoc cheatsheets are inspired by [devhints.io](https://devhints.io) from [Rico Sta. Cruz](https://twitter.com/rstacruz), and were contributed by [Paulo Valim](https://twitter.com/paulovalim) and [Yordis Prieto](https://twitter.com/alchemist_ubi).
2626

2727
## Eight features that show how ExDoc has improved developer experience over time
2828

29-
We added Cheatsheets to ExDoc because we value developer experience and believe documentation is a core aspect of it.
29+
We added cheatsheets to ExDoc because we value developer experience and believe documentation is a core aspect of it.
3030

3131
Since the beginning, one of Elixir's principles is that documentation should be a first-class citizen. What this idea means to us is that documentation should be easy to write and easy to read. ExDoc has been continuously evolving over the years, guided by this principle.
3232

3333
Here are some of the features added to ExDoc over the years that make reading and writing documentation in Elixir a joy.
3434

3535
### Beautiful and usable design
36-
As developers, we may not have the skill to make beautifully designed UIs. That doesn't mean we don't appreciate it.
3736

38-
Here's what ExDoc-based documentation looked like almost ten years ago, with its original layout based on [YARD](https://yardoc.org/).
37+
As developers, we may not have the skill to make beautifully designed UIs. That doesn't mean we don't appreciate it. Here's what documentation generated with ExDoc looked like almost ten years ago, with its original layout based on [YARD](https://yardoc.org/):
3938

40-
![](https://i.imgur.com/O9xKjR8.jpg)
39+
![Screenshot of the Phoenix v0.5.0 documentation generated with an early version
40+
of ExDoc](https://i.imgur.com/O9xKjR8.jpg)
4141

4242
Here's what it looks like today:
4343

44-
![](https://i.imgur.com/ZKI1T23.png)
44+
![Screenshot of the Phoenix v1.6.15 documentation generated with current
45+
ExDoc](https://i.imgur.com/ZKI1T23.png)
4546

46-
The evolution of ExDoc's design helped ExDoc-based documentation be more visually appealing and easier to read and navigate.
47+
The evolution of ExDoc's design helped documentation be more visually appealing and easier to read and navigate.
4748

4849
### Links to source code
4950

50-
Sometimes you're reading the docs of a library, and you want to know more about the implementation of a function. Or you found something in the documentation that could be improved and wants to help.
51-
52-
In those situations, it's helpful to go from the documentation to the source code. ExDoc makes that dead easy.
51+
Sometimes you're reading the documentation of a library, and you want to know more about the implementation of a function. Or, you found something in the documentation that could be improved and wants to help. In those situations, it's helpful to go from the documentation to the source code. ExDoc makes that dead easy. For every module, function, or page, ExDoc gives you a link that you can click to go directly to the project's source code on GitHub:
5352

54-
For every module, function, or page, ExDoc gives you a link that you can click to go directly to the project's source code inside Github:
55-
56-
![](https://i.imgur.com/PXvoeDk.gif)
53+
![Short screencast of a user clicking on the "link to source code" button on the
54+
documentation for a function](https://i.imgur.com/PXvoeDk.gif)
5755

5856
### Guides
59-
One of the most common formats of library documentation is an API reference. But depending on your needs, that's not the most approachable format. For example,it's not optimal when you're just getting started with a library or when you want to learn how to solve a specific problem using it.
6057

61-
That's why ExDoc allows writing other types of docs besides API references, like Getting Started Guides or How-tos.
58+
One of the most common formats of library documentation is an API reference. But depending on your needs, that's not the most approachable format. For example, it's not optimal when you're just getting started with a library or when you want to learn how to solve a specific problem using it. That's why ExDoc allows writing other types of docs besides API references, like *"Getting started" guides* or *How-tos*.
6259

6360
Look at how [Ecto's documentation](https://hexdocs.pm/ecto/getting-started.html) uses that, for example:
6461

65-
![](https://i.imgur.com/KInZb4x.gif)
62+
![Screencast of a user exploring the guides in the Ecto
63+
documentation](https://i.imgur.com/KInZb4x.gif)
6664

6765
### Custom grouping of modules, functions, and pages in the sidebar
6866

69-
Sometimes your library has dozens of modules. And sometimes, one given module has a large API surface area. In those situations showing the list of functions as a single large list may not be the most digestible way to be consumed.
70-
71-
For those situations, ExDoc allows modules, functions, or extra pages to be grouped in the sidebar in a way that makes more sense semantically.
67+
Sometimes your library has dozens of modules. Sometimes, one given module has a large API surface area. In those situations, showing the list of functions as a single large list may not be the most digestible way to be consumed. For those cases, ExDoc allows modules, functions, or extra pages to be grouped in the sidebar in a way that makes more sense semantically.
7268

7369
Here's an example of how Ecto use grouped functions for its `Repo` module:
7470

75-
![](https://i.imgur.com/ZE7N312.png)
71+
![Screenshot of the sidebar of the Ecto documentation, showing grouped functions
72+
in the `Ecto.Repo` module](https://i.imgur.com/ZE7N312.png)
7673

7774
Instead of listing the ~40 functions of `Ecto.Repo` as a single extensive list, it presents them grouped by five cohesive topics:
7875

@@ -82,45 +79,55 @@ Instead of listing the ~40 functions of `Ecto.Repo` as a single extensive list,
8279
- Runtime API
8380
- User callbacks
8481

85-
The same functionality is available for modules and pages (guides, how-tos, etc). Phoenix is a [good example](https://hexdocs.pm/phoenix/overview.html) of how that's used.
82+
The same functionality is available for modules and pages (guides, how-tos, and so on). Phoenix is a [good example](https://hexdocs.pm/phoenix/overview.html) of how that's used.
8683

8784
### Full-text search
8885

8986
Sometimes you don't know or don't remember the name of the function that you're looking for. For example, let's say you're looking for a function for dealing with file system directories.
9087

9188
Although there's no function or module called "directory" in Elixir, when you type "directory" in [Elixir's documentation](https://hexdocs.pm/elixir/search.html?q=directory), it will return all the entries that have the word "directory" inside the documentation. It will even return entries with variations of the word "directory", like "directories", doing a fuzzy search.
9289

93-
![](https://i.imgur.com/IHHuej8.png)
90+
![Screenshot of the result of searching for "directory" in the Elixir
91+
documentation](https://i.imgur.com/IHHuej8.png)
9492

9593
The search bar also supports autocompletion for module and function names:
9694

97-
![](https://i.imgur.com/2cmsuDi.gif)
95+
![Screencast of a user typing the word "Enum" in the search bar of Elixir's
96+
documentation and letting it autocomplete the module. Then, the user types
97+
"Range" and both modules and functions show
98+
up.](https://i.imgur.com/2cmsuDi.gif)
9899

99-
The best part is that full-text search is fully implemented on the client-side, which means ExDoc pages can be fully hosted as static pages anywhere.
100+
The best part is that full-text search is fully implemented on the client-side, which means ExDoc pages can be fully hosted as static websites (for example on GitHub Pages).
100101

101-
### Keyboard shortcut to navigate to docs of other Hex packages
102+
### Keyboard shortcuts to navigate to docs of other Hex packages
102103

103-
It's usual for an application to have many dependencies. And while coding, we usually need to read the documentation of more than one of those dependencies.
104+
It's common for an application to have dependencies. While coding, we usually need to read the documentation of more than one of those dependencies.
104105

105-
One solution is to keep a window open for each package documentation we need. But ExDoc offers another one, a keyboard shortcut to search and go to another package documentation within the same window.
106+
One solution is to keep a window open for the documentation of each dependency. However, ExDoc offers another option: a keyboard shortcut to search and go to another package documentation within the same window.
106107

107108
Here's what it looks like:
108109

109-
![](https://i.imgur.com/I9uJxUF.gif[/img])
110+
![Screencast of a user enabling the `g` shortcut to search through dependencies
111+
documentation and then using it to search for "phoenix_live" in the
112+
documentation for Nerves.](https://i.imgur.com/I9uJxUF.gif)
110113

111-
And there are more keyboard shortcuts to help you navigate within and between documentation:
114+
There are more keyboard shortcuts to help you navigate within and between documentation:
112115

113-
![](https://i.imgur.com/qdoNUx9.png)
116+
![Screenshot of the keyboard shortcuts that you can enable in
117+
ExDoc](https://i.imgur.com/qdoNUx9.png)
114118

115119
### A version dropdown to switch to other versions
116120

117-
Keeping our application updated with the latest versions of all its dependencies can be challenging. So, it's common to need to look at the documentation of an older version of a library we're using. ExDoc makes it very simple to do that.
121+
Keeping our application updated with the latest versions of all its dependencies can be challenging. So, it's common to need to look at the documentation of an older version of a library we're using. ExDoc makes it simple to do that.
118122

119123
When you access the documentation of a project, there's a dropdown that you can use to select the version you're looking for:
120124

121-
![](https://i.imgur.com/1krcY5g.gif)
125+
![Screencast of a user typing the version dropdown under the application name in
126+
the "timex" documentation, revealing all the
127+
versions.](https://i.imgur.com/1krcY5g.gif)
122128

123129
### Livebook integration
130+
124131
[Livebook](https://livebook.dev/) is a web application for writing interactive and collaborative code notebooks in Elixir.
125132

126133
One of the ways Elixir developers have been using Livebook is for documentation. Because of its interactivity capabilities, it enables the reader to play with the code right inside the documentation, which makes it great for tutorials and augmenting the user experience.
@@ -129,21 +136,24 @@ With that in mind, ExDoc offers the possibility of integrating Livebook notebook
129136

130137
Here's an [example of using Livebook inside ExDoc for writing a Usage Guide](https://hexdocs.pm/req_sandbox/usage.html):
131138

132-
![](https://i.imgur.com/FxOLs0Y.gif)
139+
![Screencast of a user navigating through the "req_sandbox" documentation,
140+
finding a Livebook, clicking "Run in Livebook", and using the Livebook that
141+
opens up on their local machine.](https://i.imgur.com/FxOLs0Y.gif)
133142

134143
### Bonus: Erlang support
135144

136-
[EEP 48](https://www.erlang.org/eeps/eep-0048) proposed a standardized way for how BEAM languages could store API documentation. That allowed any BEAM language to read documentation generated by each other.
145+
[EEP 48](https://www.erlang.org/eeps/eep-0048) proposed a standardized way for how BEAM languages could store API documentation. This allows any BEAM language to read documentation generated by each other.
137146

138-
By leveraging that work, ExDoc can generate docs for an Erlang project. For example, Telemetry is a library written in Erlang that has [its docs](https://hexdocs.pm/telemetry/readme.html) generated with ExDoc.
147+
By leveraging that work, ExDoc can generate documentation for an Erlang project. For example, Telemetry is a library written in Erlang that has [its documentation](https://hexdocs.pm/telemetry/readme.html) generated with ExDoc.
139148

140-
![](https://i.imgur.com/C4Idbuh.png)
149+
![Screenshot of "telemetry" documentation generated with
150+
ExDoc](https://i.imgur.com/C4Idbuh.png)
141151

142-
By using ExDoc to also generate docs for Erlang-based projects, we can have more consistency in the user experience along the BEAM ecosystem. See the great [`rebar3_ex_doc`](https://hexdocs.pm/rebar3_ex_doc/) plugin to get started.
152+
By using ExDoc to also generate documentation for Erlang-based projects, we can have more consistency in the user experience along the BEAM ecosystem. See the great [`rebar3_ex_doc`](https://hexdocs.pm/rebar3_ex_doc/) plugin to get started.
143153

144154
### Bonus: Doctests
145155

146-
When writing a function's documentation, it's helpful to offer code examples of how that function works. For example, here's the documentation of the `Enum.any?/1` function from Elixir's standard library:
156+
When writing documentation, it's helpful to offer code examples. For instance, here's the documentation of the `Enum.any?/1` function from Elixir's standard library:
147157

148158
```elixir
149159
@doc """
@@ -166,17 +176,12 @@ immediately and `true` is returned. In all other cases `false` is returned.
166176
"""
167177
```
168178

169-
To ensure examples do not get out of date, Elixir's test framework (ExUnit) provides a feature called doctests that allows developers to test the examples in their documentation. Doctests work by parsing out code samples starting with `iex>` from the documentation.
179+
To ensure examples do not get out of date, Elixir's test framework ExUnit provides a feature called **doctests**. This allows developers to test the examples in their documentation. Doctests work by parsing out code samples starting with `iex>` from the documentation.
170180

171181
Although this is not a feature of ExDoc, it is an essential part of Elixir's developer and documentation experience.
172182

173183
## Wrap up
174184

175-
As we can see, ExDoc has evolved a lot throughout the years!
176-
177-
As it continues to evolve into a more and more comprehensive documentation tool, we want to enable developers to keep investing more time writing the documentation itself instead of needing to spend time building custom documentation tools and websites.
178-
179-
The best part is that all you need to do to leverage many of those features is to simply document your code using the `@doc` attribute!
180-
185+
As we saw, ExDoc has evolved a lot throughout the years! As it continues to evolve into a more and more comprehensive documentation tool, we want to enable developers to keep investing more time writing the documentation itself instead of needing to spend time building custom documentation tools and websites. The best part is that all you need to do to leverage many of those features is to simply document your code using the `@doc` attribute!
181186

182187
Here's to a continuously improving documentation experience for the next years.

0 commit comments

Comments
 (0)