Project

docsmith

0.0
The project is in a healthy, maintained state
Docsmith adds snapshot-based versioning to any ActiveRecord model with zero system dependencies. • Full content snapshots (HTML, Markdown, JSON) for instant rollbacks • Format-aware diff engine: word-level diffs for Markdown, tag-atomic diffs for HTML • Document-level and range-anchored comments with threading and version migration • Per-class configuration, debounced auto-save, lifecycle events, and a clean API Perfect for wikis, CMS pages, API specs, legal documents, or any content that needs an audit trail and inline collaboration.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.12
~> 1.50
~> 1.4

Runtime

 Project Readme

Docsmith

Gem Version

Docsmith adds snapshot-based versioning, format-aware diffs, and inline comments to any ActiveRecord model — with zero system dependencies.

Features

  • Full content snapshots for HTML, Markdown, and JSON — instant rollback to any version
  • Format-aware diffs — word-level diffs for Markdown; HTML tags treated as atomic tokens
  • Inline and document-level comments with threading, resolution, and version migration
  • Debounced auto-save with per-class and global configuration
  • Lifecycle events — hook into version_created, version_restored, version_tagged
  • Clean service API — works standalone without any model mixin

Quick Start

# Gemfile
gem "docsmith"
rails generate docsmith:install
rails db:migrate
class Article < ApplicationRecord
  include Docsmith::Versionable
  docsmith_config { content_field :body; content_type :markdown }
end

article.body = "New draft"
article.save!
article.save_version!(author: current_user, summary: "First draft")

result = article.diff_from(1)
result.additions   # word-level count for markdown
result.to_html     # <ins>/<del> markup

Example App

A self-contained Sinatra demo is in demo/. It shows versioning, diffs, and comments working end-to-end — no Rails required.

cd demo
bundle install
ruby app.rb
# open http://localhost:4567

Documentation

See USAGE.md for full documentation including:

  • Installation and migration
  • Per-class and global configuration
  • Saving, querying, and restoring versions
  • Version tagging
  • Format-aware diffs (Markdown and HTML parsers)
  • Inline and document-level comments
  • Events and hooks
  • Standalone Document API
  • Configuration reference

Development

bin/setup
bundle exec rspec    # run tests
bin/console          # interactive console

How this was built

Honest note: this gem was built over two weekends using Claude Code with the superpowers plugin. Not vibe-coding — the planning, architecture decisions, and implementation were all deliberate. If you're curious how it came together, the planning docs and implementation notes are in docs/superpowers.

Early designs got ambitious fast — branching, merging, conflict resolution. Turns out that's a lot of machinery for what is ultimately a document version manager. I stripped it back to what actually matters: snapshots, diffs, and comments. You can see all the planning in docs/superpowers.

License

MIT — see LICENSE.txt.