1
- use std:: time:: { Instant , SystemTime } ;
1
+ use std:: {
2
+ collections:: HashMap ,
3
+ time:: { Instant , SystemTime } ,
4
+ } ;
2
5
3
6
use camino:: { Utf8Path , Utf8PathBuf } ;
4
7
use ecow:: EcoString ;
@@ -9,10 +12,11 @@ use gleam_core::{
9
12
analyse:: TargetSupport ,
10
13
build:: { Codegen , Compile , Mode , Options , Package , Target } ,
11
14
config:: { DocsPage , PackageConfig } ,
12
- docs:: DocContext ,
15
+ docs:: { Dependency , DependencyKind , DocContext } ,
13
16
error:: Error ,
14
17
hex,
15
18
io:: HttpClient as _,
19
+ manifest:: ManifestPackageSource ,
16
20
paths:: ProjectPaths ,
17
21
type_,
18
22
} ;
@@ -49,6 +53,26 @@ pub fn build(paths: &ProjectPaths, options: BuildOptions) -> Result<()> {
49
53
crate :: fs:: delete_directory ( & paths. build_directory_for_target ( Mode :: Prod , config. target ) ) ?;
50
54
51
55
let out = paths. build_documentation_directory ( & config. name ) ;
56
+
57
+ let manifest = crate :: build:: download_dependencies ( paths, cli:: Reporter :: new ( ) ) ?;
58
+ let dependencies = manifest
59
+ . packages
60
+ . iter ( )
61
+ . map ( |package| {
62
+ (
63
+ package. name . clone ( ) ,
64
+ Dependency {
65
+ version : package. version . clone ( ) ,
66
+ kind : match & package. source {
67
+ ManifestPackageSource :: Hex { .. } => DependencyKind :: Hex ,
68
+ ManifestPackageSource :: Git { .. } => DependencyKind :: Git ,
69
+ ManifestPackageSource :: Local { .. } => DependencyKind :: Path ,
70
+ } ,
71
+ } ,
72
+ )
73
+ } )
74
+ . collect ( ) ;
75
+
52
76
let mut built = crate :: build:: main (
53
77
paths,
54
78
Options {
@@ -60,11 +84,12 @@ pub fn build(paths: &ProjectPaths, options: BuildOptions) -> Result<()> {
60
84
root_target_support : TargetSupport :: Enforced ,
61
85
no_print_progress : false ,
62
86
} ,
63
- crate :: build :: download_dependencies ( paths , cli :: Reporter :: new ( ) ) ? ,
87
+ manifest ,
64
88
) ?;
65
89
let outputs = build_documentation (
66
90
paths,
67
91
& config,
92
+ dependencies,
68
93
& mut built. root_package ,
69
94
DocContext :: Build ,
70
95
& built. module_interfaces ,
@@ -106,6 +131,7 @@ fn open_docs(path: &Utf8Path) -> Result<()> {
106
131
pub ( crate ) fn build_documentation (
107
132
paths : & ProjectPaths ,
108
133
config : & PackageConfig ,
134
+ dependencies : HashMap < EcoString , Dependency > ,
109
135
compiled : & mut Package ,
110
136
is_hex_publish : DocContext ,
111
137
cached_modules : & im:: HashMap < EcoString , type_:: ModuleInterface > ,
@@ -121,6 +147,7 @@ pub(crate) fn build_documentation(
121
147
let mut outputs = gleam_core:: docs:: generate_html (
122
148
paths,
123
149
config,
150
+ dependencies,
124
151
compiled. modules . as_slice ( ) ,
125
152
& pages,
126
153
ProjectIO :: new ( ) ,
@@ -147,6 +174,25 @@ pub fn publish(paths: &ProjectPaths) -> Result<()> {
147
174
// Reset the build directory so we know the state of the project
148
175
crate :: fs:: delete_directory ( & paths. build_directory_for_target ( Mode :: Prod , config. target ) ) ?;
149
176
177
+ let manifest = crate :: build:: download_dependencies ( paths, cli:: Reporter :: new ( ) ) ?;
178
+ let dependencies = manifest
179
+ . packages
180
+ . iter ( )
181
+ . map ( |package| {
182
+ (
183
+ package. name . clone ( ) ,
184
+ Dependency {
185
+ version : package. version . clone ( ) ,
186
+ kind : match & package. source {
187
+ ManifestPackageSource :: Hex { .. } => DependencyKind :: Hex ,
188
+ ManifestPackageSource :: Git { .. } => DependencyKind :: Git ,
189
+ ManifestPackageSource :: Local { .. } => DependencyKind :: Path ,
190
+ } ,
191
+ } ,
192
+ )
193
+ } )
194
+ . collect ( ) ;
195
+
150
196
let mut built = crate :: build:: main (
151
197
paths,
152
198
Options {
@@ -158,11 +204,12 @@ pub fn publish(paths: &ProjectPaths) -> Result<()> {
158
204
target : None ,
159
205
no_print_progress : false ,
160
206
} ,
161
- crate :: build :: download_dependencies ( paths , cli :: Reporter :: new ( ) ) ? ,
207
+ manifest ,
162
208
) ?;
163
209
let outputs = build_documentation (
164
210
paths,
165
211
& config,
212
+ dependencies,
166
213
& mut built. root_package ,
167
214
DocContext :: HexPublish ,
168
215
& built. module_interfaces ,
0 commit comments