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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A `Makefile`, `GNUmakefile` or `*.mk` now opens as its targets instead of as source text.

shipped production is serving it deploy f21b126

opened this

A Makefile, GNUmakefile or *.mk now opens as its targets instead of as source text.

What changed

  • src/web/render/kinds.ts has a new makefile kind, matched by file name only. The kind entries are one line each in kinds.ts and renderers.ts, to keep a merge with the package.json pull easy.
  • src/web/render/makefile.ts is 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.
  • .PHONY targets carry a "phony" badge, even when .PHONY is 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 ; cmd recipe 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, define blocks, target-specific variables like all: CC=gcc, and a tab line with no target above it. Only blank lines are dropped. The .PHONY line itself also stays as source.
  • Every value is escaped by the html template. 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.ts and cover targets, phony, variables, continuation lines, unparsed lines, escaping and the cap. There is also a new case in test/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 define bodies, which show as source.

Try it Open any Makefile in a repository's file view. The header reads "N targets · N variables".

Closes #11209

commented

A Makefile, GNUmakefile or *.mk now opens as its targets instead of as source text.

What changed

  • src/web/render/kinds.ts has a new makefile kind, matched by file name only. The kind entries are one line each in kinds.ts and renderers.ts, to keep a merge with the package.json pull easy.
  • src/web/render/makefile.ts is 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.
  • .PHONY targets carry a "phony" badge, even when .PHONY is 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 ; cmd recipe 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, define blocks, target-specific variables like all: CC=gcc, and a tab line with no target above it. Only blank lines are dropped. The .PHONY line itself also stays as source.
  • Every value is escaped by the html template. 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.ts and cover targets, phony, variables, continuation lines, unparsed lines, escaping and the cap. There is also a new case in test/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 define bodies, which show as source.

Try it Open any Makefile in a repository's file view. The header reads "N targets · N variables".

commented

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.ts and bun scripts/design-lint.ts came 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.
Changes requested — before the latest 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.

commented

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.md and the others). It records the two layout decisions below.
  • Narrow screens: each table (Variables and Targets) is now wrapped in the existing table-scroll region, 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 pre rule. I picked scrolling over stacking because it keeps the three columns lined up for comparing targets, and it needs no new CSS. I dropped the makefile-view class because it had no rule. I did not take a phone-width check; the wrapper is tested, not viewed at 360 px.
  • .PHONY line: it is no longer drawn as a source row, since the phony badges already say it. The cost is that a name listed in .PHONY with 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.

commented

I merged main into the branch and pushed it (48f04b426).

  • Conflicts: they were in src/web/render/kinds.ts and src/web/render/renderers.ts. main added a dockerfile kind in the same places this pull adds makefile, so I kept both kinds throughout.
  • Test change: after the merge, test/render-kinds.test.ts failed on its "no known extension" case. main had swapped its Makefile example for Dockerfile, and each name now has its own kind. I changed the example to LICENSE, which no kind claims. The test was wrong, not the code.
  • Gate: scripts/gate.ts flagged a feature pull with no pipeline change. I added a Direction: 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, tsc and 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.
Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs