[Chore] restructure bash into its own package#9
Merged
Conversation
Cell types now live in internal/bash and internal/static. Classify dispatches all cell construction through a parsers map (keyed by language, with "static" as the reserved fallback), so internal has no dependency on any concrete cell type.
- Move rendering logic from free functions RenderBlock/RenderContent into Block.Render(), removing them from cell.go - StaticCell and BashCell now store a Block instead of raw content+indent strings, calling block.Render() directly - Output stores a Block (assembled from markers and content) instead of separate content/linePrefix fields; Render() delegates to Block.Render() - MakeOutput now takes a raw indent and computes RenderIndent internally, removing the need for callers to compute it
CellParser is now an interface with a Parse method, with CellParserFunc as a function adapter. Classify wraps errors with context. Error paths in Classify are covered by new tests using a mockery-generated MockCellParser.
The previous name borrowed markdown spec terminology that only applies to fenced code blocks. headerLine better describes what the method does across all block kinds: strip the opening delimiter and return the text on the first line.
Types are already namespaced by package (bash.Cell, static.Cell), so the repetitive prefix adds no information.
Replaces monolithic TestBashCell/TestStaticCell with separate tests per function. Introduces parseCellWith for dependency injection so the error path can be tested without constructing real block sequences, exposed to bash_test via export_test.go.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
Restructures the
internalpackage for clarity and testability.Package organisation
BashCellandStaticCellinto their own sub-packages (internal/bash,internal/static), following thepattern that language-specific implementations belong in named packages
Cellwithin their packages — the prefix was redundant given the package name (bash.Cell,static.Cell)Naming
Block.rawInfoString→headerLine: the previous name borrowed markdown spec terminology that onlyapplies to fenced code blocks;
headerLinedescribes what the method actually does across all block kinds (stripthe opening delimiter, return the first line)
Tests
TestBashCell/TestStaticCellinto per-function tests (TestMakeCellFromRaw,TestParseCell/TestParseCellWith,TestRender,TestExecute)parseCellWithinbashfor dependency injection ofOutputFromBlocks, exposed tobash_testviaexport_test.go— this lets the error-wrapping path be tested without constructing real block sequencesNotes for reviewers
The
export_test.gofile is a standard Go pattern (used in the stdlib) for exposing unexported symbols only duringtest builds. It keeps
cell_test.goinpackage bash_test(black-box) while still allowing access toparseCellWith.Checklist before requesting a review
them further would leave the codebase in intermediate awkward states.