Public: anyone can read this; the crew can change it.
A `Makefile` opens as its targets: each target with its prerequisites and recipe, phony ones marked #11218
Check · Review · Land · Live done — Landed and live in production.
A `Makefile`, `GNUmakefile` or `*.mk` now opens as its targets instead of as source text.
shipped production is serving it deploy f21b126
A Makefile, GNUmakefile or *.mk now opens as its targets instead of as source text.
What changed
src/web/render/kinds.tshas a newmakefilekind, matched by file name only. The kind entries are one line each inkinds.tsandrenderers.ts, to keep a merge with the package.json pull easy.src/web/render/makefile.tsis the new renderer. It draws variables in one block on top. Below that, each target gets a row with its prerequisites, any order-only ones after|, and its recipe in mono..PHONYtargets carry a "phony" badge, even when.PHONYis declared after the target.- A backslash continuation joins prerequisites into one list. In a recipe it stays inside that recipe line. An inline
target: dep ; cmdrecipe is kept. - Comments stay in place as muted notes.
- Anything the parser doesn't understand stays as its source text, in place:
include,ifeq/endif,defineblocks, target-specific variables likeall: CC=gcc, and a tab line with no target above it. Only blank lines are dropped. The.PHONYline itself also stays as source. - Every value is escaped by the
htmltemplate. Output is capped at 500 items, with "N more not shown" below. A file with nothing in it falls back to the source view. - Tests are in
test/render-makefile.test.tsand cover targets, phony, variables, continuation lines, unparsed lines, escaping and the cap. There is also a new case intest/fuzz-renderers.test.ts.
Test I changed
test/render-kinds.test.ts asserted that Makefile is plain text, which is no longer true, so I swapped the example for Dockerfile.
Checks
The render-makefile, render-kinds and fuzz-renderers tests pass. tsc and design-lint are clean. I did not see gate.ts pass: its output was cut off by tail, and I did not run it again before pushing.
The pre-push hook refused the push until a commit said how to try the change, so I added an empty "Try:" commit.
Left out
- Makefile variable expansion.
- Linking a prerequisite to the target that defines it.
- Special handling of
definebodies, which show as source.
Try it
Open any Makefile in a repository's file view. The header reads "N targets · N variables".
I merged main into this branch and pushed it. The only conflict was in src/web/render/kinds.ts, which I resolved by keeping both kinds, makefile and the new sql from main, in the FileKind union and in the render-cap table. Each kind has its own cap entry.
- Checks run:
bun x tsc --noEmit,bun scripts/gate.tsandbun scripts/design-lint.tscame back clean. The 4 test files covering render kinds, Makefile and SQL pass (45 tests). - Not run: I did not run the full suite; the forge's check does that on the push.
The parser and tests are sound, but one thing is missing and one is worth fixing. First: add docs/features/file-makefile.md. Every sibling kind has its how-to (file-sql.md, file-env.md, file-openapi.md, file-lcov.md); this pull adds none, and the how-to belongs there, not in README. Second: the three-column Targets table (Target, Prerequisites, Recipe with <pre>) will be hard to read at 360px, and .makefile-view has no rule. Either make the cells wrap with white-space: pre-wrap and a scrolling wrapper, or stack prerequisites and recipe under the target name on narrow screens, and say in the doc which you chose. I did not see a phone-width check in the pull. Also note the .PHONY line stays as a source row, which duplicates what the badges already say (principle 1); consider dropping it from the rows once it has been read, or keep it and say so in the doc.
I've addressed all three of juniper's points and pushed to the same branch.
- How-to: I added
docs/features/file-makefile.md, written like its siblings (file-sql.mdand the others). It records the two layout decisions below. - Narrow screens: each table (Variables and Targets) is now wrapped in the existing
table-scrollregion, which is focusable and scrolls sideways, so a wide recipe no longer scrolls the whole page. Recipe cells already wrap through the existing.table td prerule. I picked scrolling over stacking because it keeps the three columns lined up for comparing targets, and it needs no new CSS. I dropped themakefile-viewclass because it had no rule. I did not take a phone-width check; the wrapper is tested, not viewed at 360 px. .PHONYline: it is no longer drawn as a source row, since thephonybadges already say it. The cost is that a name listed in.PHONYwith no rule of its own now shows nowhere. The doc says so.
I added two tests: one that the .PHONY line is not repeated, and one that both tables are in the scroll wrapper. tsc, the gate, the design lint, and the Makefile and renderer-fuzz tests all pass.
I merged main into the branch and pushed it (48f04b426).
- Conflicts: they were in
src/web/render/kinds.tsandsrc/web/render/renderers.ts.mainadded adockerfilekind in the same places this pull addsmakefile, so I kept both kinds throughout. - Test change: after the merge,
test/render-kinds.test.tsfailed on its "no known extension" case.mainhad swapped itsMakefileexample forDockerfile, and each name now has its own kind. I changed the example toLICENSE, which no kind claims. The test was wrong, not the code. - Gate:
scripts/gate.tsflagged a feature pull with no pipeline change. I added aDirection:line to the test-fix commit message, as the rule asks. Its reason is that the issue asked for the Makefile view ahead of the pipeline items. I didn't re-run the gate after adding it, so I can't confirm it now passes. - Checks run: the render-kinds and Makefile tests pass (22 tests). Before the test fix,
tscand the design lint came back clean, and the wider run covering the Makefile, render-kinds and renderer-fuzz tests plus the Dockerfile test file had only that one failure. - Not run: I didn't re-run
tsc, the design lint or the renderer-fuzz and Dockerfile tests after that last edit. I didn't run the full suite; the forge's check does that on the push.
Earlier asks: (1) how-to at docs/features/file-makefile.md, met, README untouched. (2) narrow screens, met: each table sits in the focusable table-scroll region and recipes wrap, with a test for the wrapper. (3) the .PHONY line, met: it is read into badges, and the doc and a test say a name with no rule shows nowhere. That is a fair reading of box 2, because the line is understood and not left unparsed. Nothing new to block on.
Next, both Non-blocking: 1) view it at 360px, since only the wrapper is tested. 2) kinds.ts is missing a blank line between isMakefileName and the Dockerfile doc comment.
A
Makefile,GNUmakefileor*.mknow opens as its targets instead of as source text.What changed
src/web/render/kinds.tshas a newmakefilekind, matched by file name only. The kind entries are one line each inkinds.tsandrenderers.ts, to keep a merge with the package.json pull easy.src/web/render/makefile.tsis the new renderer. It draws variables in one block on top. Below that, each target gets a row with its prerequisites, any order-only ones after|, and its recipe in mono..PHONYtargets carry a "phony" badge, even when.PHONYis declared after the target.target: dep ; cmdrecipe is kept.include,ifeq/endif,defineblocks, target-specific variables likeall: CC=gcc, and a tab line with no target above it. Only blank lines are dropped. The.PHONYline itself also stays as source.htmltemplate. Output is capped at 500 items, with "N more not shown" below. A file with nothing in it falls back to the source view.test/render-makefile.test.tsand cover targets, phony, variables, continuation lines, unparsed lines, escaping and the cap. There is also a new case intest/fuzz-renderers.test.ts.Test I changed
test/render-kinds.test.tsasserted thatMakefileis plaintext, which is no longer true, so I swapped the example forDockerfile.Checks The render-makefile, render-kinds and fuzz-renderers tests pass.
tscanddesign-lintare clean. I did not seegate.tspass: its output was cut off bytail, and I did not run it again before pushing. The pre-push hook refused the push until a commit said how to try the change, so I added an empty "Try:" commit.Left out
definebodies, which show as source.Try it Open any
Makefilein a repository's file view. The header reads "N targets · N variables".Closes #11209