Skip to content

Feat/example tutorial and sync#258

Open
evanorti wants to merge 31 commits intoconceptsfrom
feat/example-tutorial-sync
Open

Feat/example tutorial and sync#258
evanorti wants to merge 31 commits intoconceptsfrom
feat/example-tutorial-sync

Conversation

@evanorti
Copy link
Contributor

Add the build a chain and module tutorial.

Also create a docs sync between docs files and the example repo to keep docs in sync in both locations.

@greptile-apps
Copy link

greptile-apps bot commented Mar 19, 2026

Greptile Summary

This PR adds a complete six-part "Build a Chain" tutorial series (00-overview through 05-run-and-test) covering proto definitions, keeper implementation, MsgServer/QueryServer, module wiring, and the full test workflow, along with a GitHub Actions workflow and Python transform script (scripts/docs-sync/transform.py) that keep the tutorial content in sync between cosmos/docs and cosmos/example. Concept pages across the learn/ section are updated to replace TODO placeholders with live links into the new tutorials.

Key issues found:

  • git stash does not capture untracked files in the "update existing PR" path of docs-sync-to-example.yml. When cosmos/example's default branch doesn't yet have a docs/ directory (first sync run) or when a new tutorial page is added, the transform output files are untracked and silently skipped by git stash. The subsequent git stash pop then fails with "No stash entries found", breaking the update path. Fix: use git stash --include-untracked.
  • Mintlify MDX components are not handled in the to_example transform. Several tutorial files use <Note> and <Warning> blocks; these pass through unchanged to the example repo's .md output, where they render as unstyled or invisible content in GitHub's Markdown renderer.
  • The {} query output in the quickstart is shown without explaining proto3 default-value omission, which is non-obvious for new Cosmos SDK developers.

Confidence Score: 3/5

  • Safe to merge for documentation content; the sync workflow has a logic bug that will cause CI failures on the update-PR path when untracked files are present.
  • The tutorial content itself is high quality and the concept page cross-links are all correct. The workflow's git stash bug is a real failure mode (not a theoretical one) that will surface on first sync run or when any new tutorial page is added, causing the GitHub Actions step to exit non-zero. The MDX component issue affects readability of the synced content in the example repo. These two issues in the sync infrastructure lower confidence.
  • .github/workflows/docs-sync-to-example.yml (stash bug) and scripts/docs-sync/transform.py (MDX component stripping)

Important Files Changed

Filename Overview
.github/workflows/docs-sync-to-example.yml New workflow syncing tutorial MDX files to cosmos/example. The git stash in the "update existing PR" path won't capture untracked output files, causing git stash pop to fail when docs/ doesn't exist on the default branch.
scripts/docs-sync/transform.py New bidirectional transform script. Frontmatter colon-split fix and link rewriting look correct, but Mintlify MDX components (Note, Warning, Tip) present in several tutorial files are not stripped or converted in the to_example direction, leaving invalid tags in the example repo markdown.
sdk/next/tutorials/example/02-quickstart.mdx New quickstart tutorial. Content is clear but the {} query response when the counter is 0 is shown without explaining proto3 default-value omission, which may confuse new users.
sdk/next/tutorials/example/03-build-a-module.mdx New step-by-step module building tutorial. Proto definitions, keeper, MsgServer, QueryServer, module.go, AutoCLI, and app wiring steps are accurate and well-explained. Contains a Note component affected by the transform issue.
sdk/next/tutorials/example/04-counter-walkthrough.mdx New full counter module walkthrough. Comprehensive coverage of params, authority, fee collection, sentinel errors, telemetry, AutoCLI, simulation, BeginBlock/EndBlock, and unit tests. Well-structured with comparison table and "add this to your module" patterns.
sdk/next/tutorials/example/05-run-and-test.mdx New running and testing tutorial. Covers single-node local chain, localnet, CLI reference, node config (app.toml/config.toml), unit tests, E2E tests, simulation, and lint. Commands and flags are accurate.

Last reviewed commit: "Revert "Update 04-co..."

@evanorti
Copy link
Contributor Author

evanorti commented Mar 19, 2026

@greptileai

@evanorti
Copy link
Contributor Author

@greptileai

Comment on lines +84 to +87
git push origin "$BRANCH"

gh pr comment "$PR_NUMBER" \
--repo cosmos/example \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 git stash silently skips untracked files — stash pop will fail

git stash only stashes changes to already-tracked files. When the transform writes .md files into cosmos-example/docs/ and that directory does not yet exist on cosmos/example's default branch (e.g. on the very first sync run, or whenever a new tutorial page is added), those output files are untracked. git stash prints "No local changes to stash" and exits 0 — it saves nothing. The subsequent git stash pop then fails with error: No stash entries found., aborting the entire "update existing PR" code path.

The fix is to include untracked files in the stash:

Suggested change
git push origin "$BRANCH"
gh pr comment "$PR_NUMBER" \
--repo cosmos/example \
git stash --include-untracked
git fetch origin "$BRANCH"
git checkout "$BRANCH"
git stash pop

Using --include-untracked (or the short form -u) ensures newly-created files are stashed alongside modified tracked files and correctly restored on top of the sync branch.

Comment on lines +103 to +122

def to_example(content: str) -> str:
# Extract frontmatter
fields, content = strip_frontmatter(content)
title = fields.get("title", "")

# Rewrite tutorial-local Mintlify links back to relative .md links
# e.g. /sdk/next/tutorials/example/quickstart → ./quickstart.md
content = re.sub(
rf'\(/{re.escape(TUTORIAL_BASE_PATH)}/([^)]+)\)',
r'(./\1.md)',
content,
)

# Rewrite other /sdk/... Mintlify paths (non-tutorial) to full URLs
# e.g. (/sdk/next/learn/foo) → (https://docs.cosmos.network/sdk/next/learn/foo)
content = re.sub(
rf'\(/(?!{re.escape(TUTORIAL_BASE_PATH)})([^\s)"\']+)\)',
lambda m: f'({DOCS_BASE_URL}/{m.group(1)})',
content,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Mintlify MDX components not stripped in to_example output

The to_example function rewrites links and frontmatter, but it does not handle Mintlify-specific MDX components such as <Note>, <Warning>, and <Tip>. Multiple tutorial files already use these components:

  • sdk/next/tutorials/example/01-prerequisites.mdx line 7: <Warning>This tutorial is intended for macOS and Linux systems…</Warning>
  • sdk/next/tutorials/example/02-quickstart.mdx line 9: <Note>Before continuing, make sure you have completed…</Note>
  • sdk/next/tutorials/example/03-build-a-module.mdx: <Note>Before continuing, you must follow the Prerequisites guide…</Note>

After transformation these tags are written verbatim into the example repo's .md files. <Note> and <Warning> are not standard HTML elements, so they will either be rendered as unstyled text content or stripped entirely by GitHub's Markdown renderer. The callout intent is completely lost for readers browsing the example repo on GitHub.

Consider adding a simple stripping or text-block conversion pass inside to_example, for example:

# Convert <Note>...</Note> / <Warning>...</Warning> / <Tip>...</Tip> to blockquotes
content = re.sub(
    r'<(Note|Warning|Tip)>\s*([\s\S]*?)\s*</\1>',
    lambda m: '> **' + m.group(1) + ':** ' + m.group(2).replace('\n', '\n> '),
    content,
)

This produces readable callouts in plain Markdown without requiring MDX support.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant