refactor: apply context+options function signature pattern#69
Merged
YusukeHirao merged 12 commits intomainfrom Jan 31, 2026
Merged
refactor: apply context+options function signature pattern#69YusukeHirao merged 12 commits intomainfrom
YusukeHirao merged 12 commits intomainfrom
Conversation
…nternal functions Apply monorepo-architect function signature rule to 8 internal functions: - transpile: split into TranspileContext + TranspileOptions - transpileMainContent: add TranspileMainContext + TranspileMainOptions - transpileLayout: add TranspileLayoutContext + TranspileLayoutOptions - formatHtml: split FormatHtmlContext + FormatHtmlOptions - imageSizes: add ImageSizesContext - titleList: add TitleListContext - getBreadcrumbs: add GetBreadcrumbsContext - getNavTree: add GetNavTreeContext Public API unchanged. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…unctions Apply monorepo-architect function signature rule to 2 internal functions: - applyTransforms: split into ApplyTransformsContext + ApplyTransformsOptions - setRoute: split into SetRouteContext + SetRouteOptions Updated all call sites and tests. Public API unchanged. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…Colorizer Apply monorepo-architect function signature rule to filePathColorizer: - Split into FilePathColorizerContext (rootDir) + FilePathColorizerOptions (cwd, enable, colors) Updated all call sites in: - server/route.ts - builder/build.ts - stdout/color.spec.ts Public API unchanged. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…hitect skill Add exception cases for context+options pattern: - Do not apply when all parameters are optional - Do not apply to public API functions (builder/factory functions) - Do not apply to simple functions with 1-2 required params This clarifies that the pattern is for internal APIs only and prevents forcing empty context objects. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
BREAKING CHANGE: getAssetGroup function signature changed from
getAssetGroup(options) to getAssetGroup(context, options?).
Before:
getAssetGroup({
inputDir: '/path',
outputDir: '/path',
compilerEntry: {...},
glob: '**/*.html'
})
After:
getAssetGroup(
{ inputDir: '/path', outputDir: '/path', compilerEntry: {...} },
{ glob: '**/*.html' }
)
- Split GetAssetsOptions into GetAssetGroupContext + GetAssetGroupOptions
- Update internal call sites in build.ts and assets.spec.ts
- All 155 tests passing
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…orizer
Apply exception rule: functions with only 1 required parameter should not
use context+options pattern.
Before:
filePathColorizer({ rootDir: './src' }, options)
After:
filePathColorizer('./src', options)
- Remove FilePathColorizerContext interface
- Update function signature to take rootDir directly
- Update all call sites in build.ts, route.ts, and tests
All tests passing.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…eSizes
Apply exception rule: functions with only 1 required parameter should not
use context+options pattern.
Before:
imageSizes({ elements: [...] }, options)
After:
imageSizes([...], options)
- Remove ImageSizesContext interface
- Update function signature to take elements directly
- Update call site in format.ts
All tests passing.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…eList
Apply exception rule: functions with only 1 required parameter should not
use context+options pattern.
Before:
titleList({ breadcrumbs: [...] }, options)
After:
titleList([...], options)
- Remove TitleListContext interface
- Update function signature to take breadcrumbs directly
- Update call site in page-compiler.ts
All tests passing.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add comprehensive documentation for the context+options function signature pattern and its exception cases. Changes: - Add section 5 "Function Signature Pattern" to ARCHITECTURE.md - Add section 5 "関数シグネチャパターン" to ARCHITECTURE.ja.md - Document when to apply and when NOT to apply the pattern - Include judgment criteria and code examples Context+options pattern rules: - Apply: 2+ required parameters and already receives object - Don't apply: 1 required parameter, all optional, public API, or primitives This documents the architectural decisions from recent refactoring commits: - a602d92 (getAssetGroup) - 85c3309 (filePathColorizer) - 694c0d7 (imageSizes) - cb3adc4 (titleList) All 155 tests passing. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
BREAKING CHANGE: computeOutputPath now takes a single context object instead of 4 separate parameters - Add ComputeOutputPathContext interface to types.ts - Update computeOutputPath signature (4 params → context object) - Update call site in get-file.ts - Update JSDoc example code - Update 9 test cases in output-path.spec.ts Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add DomSerializeOptions interface to utils/dom.ts - Update domSerialize signature (html + options) - Update call site in page-compiler/format.ts - Update JSDoc with example Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add GetTitleOptions interface to types.ts - Update getTitle signature (page + options) - Update call sites in get-global-data.ts and breadcrumbs.ts - Update deprecated/title.ts for consistency - Update JSDoc with examples Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Summary
This PR applies the context+options function signature pattern to internal APIs and improves code maintainability. The pattern standardizes function signatures for better readability and extensibility.
Key Changes
3 Breaking Changes (Public APIs):
computeOutputPath(kamado/path) - 4 params → context objectgetAssetGroup(kamado/data) - multiple params → context+optionsInternal API Improvements:
domSerialize: (html, hook, url?) → (html, options)getTitle: (page, optimizeTitle?, safe?) → (page, options?)filePathColorizer: removed empty context wrapperimageSizes: removed empty context wrappertitleList: removed empty context wrapperDocumentation:
Test Plan
Breaking Changes
computeOutputPath (kamado/path)
getAssetGroup (kamado/data)
Migration Guide
Update function calls to use the new signatures. All changes are type-safe and will be caught by TypeScript.
🤖 Generated with Claude Code