Skip to content

Instantly share code, notes, and snippets.

@edburns
Last active May 14, 2026 23:56
Show Gist options
  • Select an option

  • Save edburns/d4433e6f6fc7ff7d869ea503a907272b to your computer and use it in GitHub Desktop.

Select an option

Save edburns/d4433e6f6fc7ff7d869ea503a907272b to your computer and use it in GitHub Desktop.
## ghcp-sp-85-docs-gh-pages

ghcp-sp-85-docs-gh-pages

16:33 Prompt

This repository is the source code for the website https://docs.github.com/. I am looking for evidence of docs content in this repository that shows text interspersed with code samples. Is there any such content?

16:45 Response

Find docs with interspersed text and code

Ran terminal command: find /Users/edburns/workareas/github-docs-internal-00/content -name '*.md' -exec grep -cl '```' {} ; | head -40

Ran terminal command: grep -rlc '```' /Users/edburns/workareas/github-docs-internal-00/content/ | awk -F: '$2 >= 5' | sort -t: -k2 -nr | head -30

Ran terminal command: grep -rc '```' /Users/edburns/workareas/github-docs-internal-00/content/ 2>/dev/null | awk -F: '{print $NF, $0}' | sort -rn | head -30

Read , lines 1 to 60

Read , lines 1 to 60

Read , lines 1 to 60

Read , lines 1 to 60

Read , lines 1 to 60

Read , lines 100 to 200

Read , lines 60 to 160

Read , lines 60 to 160

Read , lines 60 to 170

Read , lines 55 to 120

Read , lines 1 to 100

Yes, there is plenty of such content. The content directory is full of tutorials and how-to guides that interleave explanatory prose with code samples. Here are five strong examples:

File Pattern
building-a-cli-with-a-github-app.md Step-by-step tutorial — each setup step has a prose explanation followed by a code block
building-ci-checks-with-a-github-app.md Guided walkthrough alternating between config instructions and terminal/Ruby code blocks
workflow-commands.md Reference doc — each workflow command gets a prose explanation then bash/PowerShell examples
using-the-api-to-manage-projects.md API cookbook — each task has a goal description, then curl and gh CLI code blocks
generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent.md Procedural how-to — numbered steps alternate between prose and commands with expected output

A typical example from the CLI tutorial looks like:

  1. Add these dependencies to the top of app_cli.rb:

    require "net/http"
    require "json"

    These are all part of the Ruby standard library, so you don't need to install any gems.

  2. Add the following main function that will serve as an entry point…

    def main
      case ARGV[0]
      

This "prose → code → prose → code" pattern is the dominant authoring style across the tutorials, how-to guides, and API reference pages in this repo.> require "net/http"

require "json"


These are all part of the Ruby standard library, so you don't need to install any gems.

1. Add the following `main` function that will serve as an entry point…

```ruby
def main
  case ARGV[0]
  …

This "prose → code → prose → code" pattern is the dominant authoring style across the tutorials, how-to guides, and API reference pages in this repo.

16:46 Prompt

Do any of these have a UI control where there are per-language user selectable samples? That is, allow the author to create content where there are several choices of language for how to do the thing that is being documented?

16:48 Response

Searched for regex tool-switcher|codetabs|code-tabs|language-switcher (**/content/**/*.md), 10 results

Searched for text annotate|annotation (**/contributing/code-annotations.md), no results

Read

Searched for regex allTools|all-tools (**/src/tools/**), 9 results

Read

Searched for regex \{%\s*(bash|javascript|curl|ruby|python|powershell)\s*%\} (**/content/**/*.md), 15 results

Read

Let me look at a concrete example of this in action:

Read , lines 15 to 120

Yes — this repo has a "tool switcher" UI control that does exactly what you're describing. Here's how it works:

The Tool Switcher

The tool picker is defined in all-tools.ts and rendered by ToolPicker.tsx. It provides a tab bar at the top of an article, letting readers choose between tools/languages like curl, JavaScript, GitHub CLI, Bash, PowerShell, etc.

Important caveat

Per the creating-tool-switchers-in-articles.md guidelines, this control is not intended for showing code samples in different programming languages. It's meant for when the tasks or concepts themselves differ depending on the tool. The docs explicitly say: "Do not use the tool switcher just to show examples in different languages."

So while the mechanism exists and could technically switch between language-specific code samples, its sanctioned use is for tool-specific workflow differences (e.g., doing something via the web UI vs. CLI vs. Desktop app), not as a generic multi-language code sample picker.The reader sees a tool picker with "curl" and "GitHub CLI" tabs and only the selected tool's content is shown.

How authors use it

Authors wrap per-tool content in Liquid tags. For example, in using-the-api-to-manage-projects.md, the same API call is shown for both curl and gh cli:

{% curl %}
```shell
curl --request POST \
  --url https://api.github.com/graphql \
  --header 'Authorization: Bearer TOKEN' \
  --data '{"query":"query{organization(login: \"ORGANIZATION\") {projectV2(number: NUMBER){id}}}"}'

{% endcurl %}

{% cli %}

gh api graphql -f query='
  query{
    organization(login: "ORGANIZATION"){
      projectV2(number: NUMBER) { id }
    }
  }'

{% endcli %}


The reader sees a tool picker with "curl" and "GitHub CLI" tabs and only the selected tool's content is shown.

### Available tools

There are **25 tool identifiers** registered in `allTools`, including programming languages (`javascript`, `bash`, `powershell`), IDEs (`vscode`, `jetbrains`, `visualstudio`, `eclipse`, `xcode`), and GitHub-specific tools (`cli`, `webui`, `desktop`, `codespaces`, `mobile`, etc.).

### Important caveat

Per the [creating-tool-switchers-in-articles.md](content/contributing/writing-for-github-docs/creating-tool-switchers-in-articles.md) guidelines, this control is **not intended for showing code samples in different programming languages**. It's meant for when the **tasks or concepts themselves differ** depending on the tool. The docs explicitly say: *"Do not use the tool switcher just to show examples in different languages."*

So while the mechanism exists and could technically switch between language-specific code samples, its sanctioned use is for tool-specific workflow differences (e.g., doing something via the web UI vs. CLI vs. Desktop app), not as a generic multi-language code sample picker.The reader sees a tool picker with "curl" and "GitHub CLI" tabs and only the selected tool's content is shown.

### Available tools

There are **25 tool identifiers** registered in `allTools`, including programming languages (`javascript`, `bash`, `powershell`), IDEs (`vscode`, `jetbrains`, `visualstudio`, `eclipse`, `xcode`), and GitHub-specific tools (`cli`, `webui`, `desktop`, `codespaces`, `mobile`, etc.).

### Important caveat

Per the [creating-tool-switchers-in-articles.md](content/contributing/writing-for-github-docs/creating-tool-switchers-in-articles.md) guidelines, this control is **not intended for showing code samples in different programming languages**. It's meant for when the **tasks or concepts themselves differ** depending on the tool. The docs explicitly say: *"Do not use the tool switcher just to show examples in different languages."*

So while the mechanism exists and could technically switch between language-specific code samples, its sanctioned use is for tool-specific workflow differences (e.g., doing something via the web UI vs. CLI vs. Desktop app), not as a generic multi-language code sample picker.

Similar code found with 1 license type
@edburns

edburns commented May 14, 2026

Copy link
Copy Markdown
Author

What does one do when one wants to show examples in different languages?

The short answer: there is no dedicated "per-language code sample picker" in this repository. The docs site doesn't have a built-in UI control for toggling between the same code example in Python vs. JavaScript vs. Ruby, etc.

When an author needs to show the same thing in multiple languages, the approach in this repo is simply to list the code blocks sequentially in the article, one after another, each with its own language-tagged fenced code block:

```javascript copy
const result = await octokit.request('GET /repos/{owner}/{repo}', { ... })
```

```python copy
result = octokit.request('GET /repos/{owner}/{repo}', { ... })
```

There's no collapsing or tab-switching — the reader sees all variants on the page.

The site does have three related switching mechanisms, but none is a language-specific code sample picker:

  1. Tool switcher ({% cli %}, {% curl %}, {% webui %}, etc.) — switches entire sections of content by tool, not by programming language. Explicitly not for "show the same example in different languages."

  2. OS switcher ({% mac %}, {% linux %}, {% windows %}) — switches instructions by operating system.

  3. Code annotations (layout: inline) — a two-pane layout with code on the left and explanatory annotations on the right. Enhances a single code block, doesn't switch between languages.

So if you're looking for a tabbed, per-language code sample picker (like what you see on docs from Stripe, Twilio, or Microsoft Learn), this repo does not have one. Multi-language examples are presented as sequential code blocks on the page.

Completed: Investigate code examples presentation methods (3/4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment