Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test/tmp
test/version_tmp
tmp
*.DS_STORE
.devbox/
build/
.cache
.vagrant
Expand Down
49 changes: 49 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Overview

This is the Drip API documentation site (developer.drip.com) — a [Slate](https://github.com/lord/slate)-based static site built with Middleman. Content is Markdown; there are no tests or linters.

## Commands

```bash
bundle install # install dependencies (Ruby 2.7.6 per .tool-versions)
bundle exec middleman server # serve locally at http://localhost:4567
bundle exec middleman build # build static site into build/
script/release # deploy main to production (GitHub Pages via middleman-deploy)

ruby script/generate-docs # regenerate source/includes/rest/_*.md from spec/
ruby script/verify-docs # check generated md matches the committed partials
npx @redocly/cli preview-docs spec/rest-v2.yaml # Redoc preview of the REST API
```

## Architecture

All documentation renders into a single page from `source/index.html.md`. That file's YAML frontmatter contains four ordered include lists (`includes_rest_api`, `includes_js_api`, `includes_cdc`, `includes_shopper_activity`), which `source/layouts/layout.erb` iterates to pull in partials from `source/includes/{rest,js,cdc,shopper_activity}/`.

To add a new documentation section: create `source/includes/<group>/_<name>.md` and add `<group>/<name>` to the matching frontmatter list in `source/index.html.md` (order in the list controls order on the page and in the table of contents).

### Content conventions (see any file in `source/includes/rest/` for an example)

- Each partial starts with a `#` heading (resource name) and `##` headings per endpoint.
- Code samples appear in fenced blocks tagged `shell`, `ruby`, or `javascript` — these become the language tabs defined in `index.html.md` frontmatter (`language_tabs`). Provide all three languages for REST endpoints; Ruby examples use the `drip` gem, JavaScript uses `drip-nodejs`.
- Blockquote lines (`> ...`) immediately above code blocks become annotations displayed in the dark code column.
- JSON response examples use ```` ```json ```` blocks; request/response property documentation uses raw HTML `<table>` elements.

### Custom Middleman plumbing (`lib/`)

- `multilang.rb` — tags rendered code blocks so the JS language switcher can toggle them.
- `unique_head.rb` — de-duplicates generated heading anchor IDs.
- `toc_data.rb` — builds the left-nav table of contents from H1/H2/H3 headings.
- `openapi_slate.rb` — converts an OpenAPI resource fragment into a Slate `_*.md` partial (used by `script/generate-docs` / `script/verify-docs`).

### REST docs are migrating to OpenAPI (`spec/`)

The REST partials in `source/includes/rest/` are being moved to a spec-as-source-of-truth model: each resource is described as OpenAPI 3.1 in `spec/fragments/`, **Redoc** renders the aggregator `spec/rest-v2.yaml`, and the custom generator reproduces the existing Slate markdown so the public site is unchanged. See `spec/README.md` for the workflow and the `x-slate` presentation-extension reference.

- Edit the OpenAPI fragment, not the generated `_<resource>.md`, for any resource that has a matching `spec/fragments/<resource>.yaml`. Regenerate with `ruby script/generate-docs <resource>` and verify with `ruby script/verify-docs <resource>`.
- The conceptual partials (`_authentication.md`, `_rate_limiting.md`, `_pagination.md`, `_errors.md`, `_webhook_events.md`) are hand-authored and **not** generated.
- Migration status: all 14 REST resources are generated from `spec/fragments/`. `tags`, `custom_fields`, `accounts`, `users`, `conversions`, `forms`, `events`, `webhooks`, `batch_api`, `campaigns`, `subscribers`, `workflows`, `broadcasts` pass `verify-docs` (NORM); `orders` differs only by incidental blank lines. The larger pages (`subscribers`, `campaigns`, `workflows`, `broadcasts`, `batch_api`) were regenerated as canonical output, so their committed `_*.md` reflects the generator (e.g. full response JSON instead of `{ ... }` placeholders, schema-derived tables). Run `ruby script/verify-docs` for current status.
- Open item: the published Batch API page also documents three **v3 Shopper Activity** batch endpoints (cart/order/product `batch`). These are not part of the `rest-v2` spec; they're currently carried verbatim in `spec/fragments/batch_api.yaml` under `x-slate.footer`. Long term they should move to a dedicated shopper-activity spec and be cross-linked.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ gem 'middleman-syntax', '~> 3.0.0'
gem 'nokogiri', '~> 1.18.9'
gem 'redcarpet', '~> 3.5.1'
gem 'rouge', '~> 2.0.5'
# Removed from the Ruby stdlib in 3.x; still required by middleman/middleman-deploy
gem 'webrick'
gem 'net-ftp'
12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GEM
coffee-script-source (1.12.2)
concurrent-ruby (1.1.9)
contracts (0.13.0)
date (3.5.1)
dotenv (2.7.6)
erubis (2.7.0)
execjs (2.8.1)
Expand Down Expand Up @@ -83,6 +84,11 @@ GEM
rouge (~> 2.0)
mini_portile2 (2.8.9)
minitest (5.15.0)
net-ftp (0.3.9)
net-protocol
time
net-protocol (0.2.2)
timeout
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
net-ssh (4.2.0)
Expand Down Expand Up @@ -116,10 +122,14 @@ GEM
thor (1.2.1)
thread_safe (0.3.6)
tilt (2.0.10)
time (0.4.2)
date
timeout (0.6.1)
tzinfo (1.2.10)
thread_safe (~> 0.1)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
webrick (1.9.2)

PLATFORMS
ruby
Expand All @@ -130,9 +140,11 @@ DEPENDENCIES
middleman-deploy (~> 2.0.0.pre.alpha)
middleman-sprockets (~> 4.1.0)
middleman-syntax (~> 3.0.0)
net-ftp
nokogiri (~> 1.18.9)
redcarpet (~> 3.5.1)
rouge (~> 2.0.5)
webrick

RUBY VERSION
ruby 2.3.3p222
Expand Down
9 changes: 9 additions & 0 deletions config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Ruby 3.0 removed URI.escape, which middleman-core 4.3 still calls when
# writing build output. Restore it on modern Rubies.
# (config.rb is instance_eval'd by Middleman, so target ::URI explicitly.)
unless ::URI.respond_to?(:escape)
::URI.define_singleton_method(:escape) do |value|
::URI::DEFAULT_PARSER.escape(value)
end
end

# Unique header generation
require './lib/unique_head.rb'

Expand Down
28 changes: 28 additions & 0 deletions devbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.10.6/.schema/devbox.schema.json",
"packages": {
"ruby": "3.3.5",
"bundler": "2.5",
"nodejs": "24",
"libyaml": {
"version": "latest",
"outputs": ["out", "dev"]
},
"libffi": "latest",
"pkg-config": "latest"
},
"env": {
"BUNDLE_BUILD__SASSC": "--disable-lto"
},
"shell": {
"scripts": {
"install": "bundle install",
"server": "bundle exec middleman server",
"docs:generate": "ruby script/generate-docs",
"docs:verify": "ruby script/verify-docs",
"redoc:preview": "npx --yes @redocly/cli@latest preview-docs spec/rest-v2.yaml",
"redoc:lint": "npx --yes @redocly/cli@latest lint spec/rest-v2.yaml",
"redoc:bundle": "npx --yes @redocly/cli@latest bundle spec/rest-v2.yaml -o build/openapi/rest-v2.yaml"
}
}
}
Loading