Philosophy docs and code fixes - #434
Conversation
- Replace `using DocStringExtensions` with `import DocStringExtensions: TYPEDEF, TYPEDSIGNATURES` in all submodules (CTBase.jl, Core.jl, Descriptions.jl, Extensions.jl, Unicode.jl) - Remove useless `using Base: Base` from CTBase.jl - Restructure test_exceptions.jl to follow module + callable pattern with proper qualification - Use `import CTBase.Exceptions` instead of `using CTBase` in tests - Add VERBOSE/SHOWTIMING constants with fallback to defaults when TestOptions not available These changes align the codebase with the philosophy defined in dev/philosophy/modules.md and dev/philosophy/testing-creation.md.
Macros like `@testset` must be imported with `using` not `import`. Changed from `import Test` to `using Test` in test_exceptions.jl.
P0 - Bug Fixes: - TestRunner auto-discovery: Fixed non-recursive test discovery (ext/TestRunner.jl:614) Now uses _collect_test_files_recursive instead of flat readdir P1 - Typed Exceptions (Tenet 6): Replaced all untyped error() and ArgumentError with structured CTBase exceptions P1a - src/Exceptions/types.jl: - Fixed 2 occurrences of invalid Julia syntax catch e::CTBase.Exceptions.CTException → catch e + e isa ... || rethrow() P1b - ext/TestRunner.jl (7 replacements): - 3 × error() in _resolve_test → CTBase.Exceptions.IncorrectArgument - 1 × error() in _run_single_test (function missing after include) → PreconditionError - 1 × error() in run_tests (subdirectory "test" forbidden) → PreconditionError - 2 × ArgumentError in _normalize_available_tests → IncorrectArgument P1c - ext/CoveragePostprocessing.jl (4 replacements): - 4 × error() → PreconditionError P1d - ext/DocumenterReference.jl (2 replacements): - public && private both false → IncorrectArgument - Invalid element in primary_modules → IncorrectArgument P1e - ext/TestRunner.jl docstring: - Fixed incorrect output in _progress_bar docstring (width=20 → 10 blocks, not 20) P1f - Test updates: - Updated 7 test files to reflect new exception types Code cleanup: - Removed circular import using CTBase from src/Exceptions/Exceptions.jl - Removed redundant using DocStringExtensions from src/Descriptions/types.jl All tests pass: 1161/1161
Updated Summary (P2 completed)This PR adds philosophy documentation and applies code standards to align with the control-toolbox ecosystem conventions. Documentation Added
Code Improvements - Completed (P0, P1, P2)P0 - Bug Fixes
P1 - Typed Exceptions (Tenet 6)Replaced all untyped P1a - src/Exceptions/types.jl
P1b - ext/TestRunner.jl (7 replacements)
P1c - ext/CoveragePostprocessing.jl (4 replacements)
P1d - ext/DocumenterReference.jl (2 replacements)
P1e - ext/TestRunner.jl docstring
P1f - Test updates
P2 - Import Qualification & Code Cleanup
Previous Code Improvements (from earlier commits)
Remaining Work (P3)P3 - Qualified Test Imports
TestingAll tests pass: 1161/1161 Stack PositionCTBase is the foundational package in the stack: |
P2 - Import Qualification & Code Cleanup: - ext/TestRunner.jl: using DocStringExtensions → import DocStringExtensions: TYPEDEF, TYPEDSIGNATURES - ext/CoveragePostprocessing.jl: using Coverage → using Coverage: Coverage - Removed dead ternary branches (ext/TestRunner.jl:447, 332) - Fixed byte-indexing path slicing → use relpath() (ext/CoveragePostprocessing.jl:347) - Fixed collision risk in cov file flattening → use normalized flat names (ext/CoveragePostprocessing.jl:221) All tests pass: 1161/1161
Additional Changes - Documentation Improvementsdocs/make.jl
src/Exceptions/types.jl - Docstring RefactoringRewrote docstrings for better consistency with philosophy standards: ExtensionError
SolverFailure
src/Extensions/Extensions.jl - Cross-Reference Fixes
These changes resolve Documenter warnings about unresolved TestingAll tests pass: 1161/1161 Documentation builds successfully with no extension errors. |
…ences docs/make.jl: - Changed from Pkg.activate/instantiate to pushfirst!(LOAD_PATH, ...) for faster builds src/Exceptions/types.jl: - Added $(TYPEDEF) macro to ExtensionError and SolverFailure - Simplified docstrings to focus on core functionality - Moved constructor throws to # Throws section - Consolidated examples and removed redundant sections - Added cross-references to related exception types src/Extensions/Extensions.jl: - Added example code blocks for CoveragePostprocessingTag, AbstractTestRunnerTag, TestRunnerTag - Fixed cross-references from CTBase.* to CTBase.Extensions.* docs/: - Updated guide files and index - Added getting-started.md - Updated Project.toml and README.md All tests pass: 1161/1161 Documentation builds successfully
- Bumped version to 0.18.15-beta in Project.toml - Added comprehensive changelog entry for 0.18.15-beta covering: - Philosophy documentation additions - Documentation build improvements - Bug fixes (TestRunner auto-discovery, typed exceptions) - Code quality improvements (import qualification, cleanup) - Added non-breaking note to BREAKINGS.md for 0.18.15-beta - All changes are internal or documentation-only; no breaking changes
Added `types: [labeled, synchronize, opened, reopened]` to pull_request triggers in CI.yml and Documentation.yml for better control over when workflows run on PRs.
Updated Summary
This PR adds philosophy documentation and applies code standards to align with the control-toolbox ecosystem conventions.
Documentation Added
These documents are adapted from CTFlows to be generic for all packages in the ecosystem.
Code Improvements - Completed (P0, P1)
P0 - Bug Fixes
_collect_test_files_recursiveinstead of flatreaddir.P1 - Typed Exceptions (Tenet 6)
Replaced all untyped
error()andArgumentErrorwith structured CTBase exceptions:P1a - src/Exceptions/types.jl
catch e::CTBase.Exceptions.CTException→catch e+e isa ... || rethrow()P1b - ext/TestRunner.jl (7 replacements)
error()in_resolve_test→CTBase.Exceptions.IncorrectArgumenterror()in_run_single_test(function missing after include) →PreconditionErrorerror()inrun_tests(subdirectory "test" forbidden) →PreconditionErrorArgumentErrorin_normalize_available_tests→IncorrectArgumentP1c - ext/CoveragePostprocessing.jl (4 replacements)
error()→PreconditionErrorP1d - ext/DocumenterReference.jl (2 replacements)
public && privateboth false →IncorrectArgumentprimary_modules→IncorrectArgumentP1e - ext/TestRunner.jl docstring
_progress_bardocstring (width=20 → 10 blocks, not 20)P1f - Test updates
Previous Code Improvements (from earlier commits)
using DocStringExtensions→import DocStringExtensions: TYPEDEF, TYPEDSIGNATURES(5 files)using Base: Basefrom CTBase.jlRemaining Work (P2, P3)
P2 - Import Qualification & Code Cleanup
using DocStringExtensions→import DocStringExtensions: TYPEDEF, TYPEDSIGNATURESusing Coverage→using Coverage: Coverageusing CTBasefrom src/Exceptions/Exceptions.jlusing DocStringExtensionsfrom src/Descriptions/types.jlP3 - Qualified Test Imports
import Test+import CTBase.Exceptionswith qualified callsTesting
All tests pass: 1161/1161
Stack Position
CTBase is the foundational package in the stack:
CTBase → CTModels → CTFlows → CTSolvers → OptimalControl