Code and data

Code blocks

Commands and code with syntax colours and a copy button.

A code block keeps spacing exactly as written, colours the syntax for its language, and gives readers a copy button. Pick the language in the block's menu.

php artisan schedule:run
public function handle(Request $request): Response
{
    $site = $request->user()->sites()->findOrFail($request->integer('site'));

    return response()->json(['published' => $site->isPublished()]);
}
{
  "name": "Writing with JustDocs",
  "visibility": "public",
  "languages": ["en"]
}

Good code blocks

  • Show what to type, not the prompt: php artisan migrate, not $ php artisan migrate.
  • Use placeholders that are clearly placeholders, such as your-domain.example.
  • Keep examples short enough to read without scrolling. Link to the full file when it's long.
  • For one word inside a sentence, such as a file name, use inline code instead: storage/.