You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Manual/BuildTools/Lake/CLI.lean
+101Lines changed: 101 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,7 @@ COMMANDS:
41
41
lint lint the package using the configured lint driver
42
42
check-lint check if there is a properly configured lint driver
43
43
clean remove build outputs
44
+
shake minimize imports in source files
44
45
env <cmd> <args>... execute a command in Lake's environment
45
46
lean <file> elaborate a Lean file in Lake's context
46
47
update update dependencies and save them to the manifest
@@ -707,6 +708,106 @@ Builds the imports of the given {lakeMeta}`file` and then runs `lean` on it usin
707
708
The `lean` process is executed in {ref "lake-environment"}[Lake's environment].
708
709
:::
709
710
711
+
# Module Imports
712
+
713
+
```lakeHelp shake
714
+
Minimize imports in Lean source files
715
+
716
+
USAGE:
717
+
lake shake [OPTIONS] [<MODULE>...]
718
+
719
+
Checks the current project for unused imports by analyzing generated `.olean`
720
+
files to deduce required imports and ensuring that every import contributes
721
+
some constant or other elaboration dependency.
722
+
723
+
ARGUMENTS:
724
+
<MODULE> A module path like `Mathlib`. All files transitively
725
+
reachable from the provided module(s) will be checked.
726
+
If not specified, uses the package's default targets.
727
+
728
+
OPTIONS:
729
+
--force Skip the `lake build --no-build` sanity check
730
+
--keep-implied Preserve imports implied by other imports
731
+
--keep-prefix Prefer parent module imports over specific submodules
732
+
--keep-public Preserve all `public` imports for API stability
733
+
--add-public Add new imports as `public` if they were in the
734
+
original public closure
735
+
--explain Show which constants require each import
736
+
--fix Apply suggested fixes directly to source files
737
+
--gh-style Output in GitHub problem matcher format
738
+
739
+
ANNOTATIONS:
740
+
Source files can contain special comments to control shake behavior:
741
+
742
+
* `module-- shake: keep-downstream`
743
+
Preserves this modulein all downstream modules
744
+
745
+
* `module-- shake: keep-all`
746
+
Preserves all existing imports in this module
747
+
748
+
* `import X -- shake: keep`
749
+
Preserves this specific import
750
+
```
751
+
752
+
::::lake shake "[options...] [module ...]"
753
+
754
+
Checks the current project for unused imports by analyzing generated {tech}[`.olean` files] to deduce required imports, ensuring that every import contributes some constant or other elaboration dependency.
755
+
756
+
If a {lakeMeta}`module` is specified, then it and all files that are transitively reachable from it are checked. Otherwise, the package's {tech}[default targets] are checked.
757
+
758
+
:::paragraph
759
+
Source files can contain special comments to control the behavior of {lake}`shake`:
760
+
761
+
: `module-- shake: keep-downstream`
762
+
763
+
Preserves this modulein all downstream modules.
764
+
765
+
: `module-- shake: keep-all`
766
+
767
+
Preserves all existing imports in this module.
768
+
769
+
: `import X -- shake: keep`
770
+
771
+
Preserves this specific import.
772
+
:::
773
+
774
+
:::paragraph
775
+
The {lakeMeta}`options` may be:
776
+
777
+
: `--force`
778
+
779
+
Skip the `lake build --no-build` sanity check
780
+
781
+
: `--keep-implied`
782
+
783
+
Preserve imports implied by other imports
784
+
785
+
: `--keep-prefix`
786
+
787
+
Prefer parent module imports over specific submodules
788
+
789
+
: `--keep-public`
790
+
791
+
Preserve all `public` imports for API stability
792
+
793
+
: `--add-public`
794
+
795
+
Add new imports as `public` if they were in the original public closure
0 commit comments