DEV Community

Cover image for Docs-as-Code: Why Documentation Should Live With Your Code
Arto Baltayan
Arto Baltayan

Posted on

Docs-as-Code: Why Documentation Should Live With Your Code

If not well maintained, a major problem with documentation is that it
falls behind the software it describes. Changes are made, a feature gets
updated, parameters are renamed, but the documentation still reflects
the previous version. Developers trying to understand a system through
the existing documentation are left confused.

Docs-as-Code aims to solve this problem by treating documentation the
same way developers treat code, rather than something completely
separate. In this approach, documentation is written, versioned,
reviewed, and published using the same tools and workflows used to build
the software.

Tools such as Git and platforms like GitHub make this possible. Let's
take a closer look.

What Docs-as-Code Means

Docs-as-Code is a simple concept in theory. In practice, the learning
curve can be a bit steeper, especially for technical writers unfamiliar
with the tools commonly used by software engineers.

At its core, Docs-as-Code means that documentation should live alongside
the code it describes. Instead of writing documentation in a separate
system like a wiki, it should be stored directly where the code exists.
In other words, documentation files (often written in Markdown) should
be located in the same repository as the application or API they
describe.

Because the documentation lives in the same repository, it becomes part
of the same workflow, evolving at the same time and in the same way as
the application. When a new feature is added, the updated documentation
can be included in the same commit or pull request.

A Docs-as-Code workflow might not look much different from what an
engineering team is already used to:

  • A developer adds or changes a feature.
  • Documentation for that feature is updated in the same repository.
  • Both code and documentation changes are reviewed through a pull request.
  • Once approved, the changes are merged together.

In this way, the documentation reflects the changing code. It is not
lagging behind—it evolves alongside it.

Why Teams Should Use Docs-as-Code

More organizations are adopting Docs-as-Code as part of their
engineering workflow. Following are two of the most compelling reasons.

Version Control

When documentation lives in the same repository as the code and is
tracked by Git, team members can see exactly what changed, when it
changed, and who made the change. If something is incorrect or unclear,
it is easy to revert to a previous version.

This level of visibility is rarely available in traditional
documentation systems. It comes from treating documentation files the
same way as source code, rather than storing them separately.

Collaboration

With this approach, documentation engineers and developers work in the
same space, alongside each other. This makes collaboration more natural
and efficient. A pull request that introduces a new feature can include
the corresponding documentation updates, allowing reviewers to comment
on both at the same time.

This shifts the mindset of documentation being treated as a separate
task. Instead, it becomes part of the normal engineering workflow. The
result is straightforward: documentation stays current because it
evolves with the code.

The Challenges of Docs-as-Code

Docs-as-Code has clear advantages, but it also comes with challenges.
The most significant barrier is the learning curve.

Technical writers and documentation specialists need to become familiar
with tools commonly used in software development. This includes
command-line tools, markup formats like Markdown, and version control
systems such as Git.

Without a basic understanding of these tools, it can be difficult to
keep up with the workflow. A certain level of technical knowledge is
required, and for some teams, that adjustment can take time.

Conclusion

Docs-as-Code represents a shift in how engineering teams approach
documentation. Rather than being an afterthought, documentation becomes
an integrated part of the software development lifecycle.

When documentation lives alongside the code, it becomes part of the
normal workflow. This helps ensure that it evolves with the application,
making it easier to maintain, more up to date, and more accurate.

That is the ultimate goal: documentation that actually serves its users
well over time.

Top comments (0)