8
8
use std:: fs;
9
9
use std:: path:: PathBuf ;
10
10
11
- use crate :: lsp:: inputs:: documentation:: Documentation ;
12
11
use crate :: lsp:: inputs:: package_description:: Description ;
13
12
use crate :: lsp:: inputs:: package_namespace:: Namespace ;
14
13
@@ -21,7 +20,6 @@ pub struct Package {
21
20
22
21
pub description : Description ,
23
22
pub namespace : Namespace ,
24
- pub documentation : Documentation ,
25
23
26
24
// List of symbols exported via NAMESPACE `export()` directives and via
27
25
// `DocType{data}`. Note the latter should only apply to packages with
@@ -32,38 +30,21 @@ pub struct Package {
32
30
}
33
31
34
32
impl Package {
35
- pub fn new (
36
- path : PathBuf ,
37
- description : Description ,
38
- namespace : Namespace ,
39
- documentation : Documentation ,
40
- ) -> Self {
33
+ pub fn new ( path : PathBuf , description : Description , namespace : Namespace ) -> Self {
41
34
// Compute exported symbols. Start from explicit NAMESPACE exports.
42
- let mut exported_symbols = namespace. exports . clone ( ) ;
43
-
44
- // Add exported datasets. Ideally we'd only do that for packages
45
- // specifying `LazyData: true`.
46
- let exported_datasets = documentation. rd_files . iter ( ) . filter_map ( |rd| {
47
- if rd. doc_type == Some ( crate :: lsp:: inputs:: documentation_rd_file:: RdDocType :: Data ) {
48
- rd. name . clone ( )
49
- } else {
50
- None
51
- }
52
- } ) ;
53
- exported_symbols. extend ( exported_datasets) ;
35
+ let exported_symbols = namespace. exports . clone ( ) ;
54
36
55
37
Self {
56
38
path,
57
39
description,
58
40
namespace,
59
- documentation,
60
41
exported_symbols,
61
42
}
62
43
}
63
44
64
45
#[ cfg( test) ]
65
46
pub fn from_parts ( path : PathBuf , description : Description , namespace : Namespace ) -> Self {
66
- Self :: new ( path, description, namespace, Default :: default ( ) )
47
+ Self :: new ( path, description, namespace)
67
48
}
68
49
69
50
/// Load a package from a given path.
@@ -92,20 +73,10 @@ impl Package {
92
73
Namespace :: default ( )
93
74
} ;
94
75
95
- let documentation_path = package_path. join ( "man" ) ;
96
- let documentation = match Documentation :: load_from_folder ( & documentation_path) {
97
- Ok ( documentation) => documentation,
98
- Err ( err) => {
99
- tracing:: warn!( "Can't load package documentation: {err:?}" ) ;
100
- Documentation :: default ( )
101
- } ,
102
- } ;
103
-
104
76
Ok ( Some ( Self :: new (
105
77
package_path. to_path_buf ( ) ,
106
78
description,
107
79
namespace,
108
- documentation,
109
80
) ) )
110
81
}
111
82
@@ -130,57 +101,3 @@ impl Package {
130
101
}
131
102
}
132
103
}
133
-
134
- #[ cfg( test) ]
135
- mod tests {
136
- use super :: * ;
137
- use crate :: lsp:: inputs:: documentation_rd_file:: RdDocType ;
138
- use crate :: lsp:: inputs:: documentation_rd_file:: RdFile ;
139
- use crate :: lsp:: inputs:: package_description:: Description ;
140
- use crate :: lsp:: inputs:: package_namespace:: Namespace ;
141
-
142
- #[ test]
143
- fn test_exported_symbols_combining_namespace_and_rd_files ( ) {
144
- let namespace = Namespace {
145
- exports : vec ! [ "foo" . to_string( ) , "bar" . to_string( ) ] ,
146
- ..Default :: default ( )
147
- } ;
148
-
149
- let rd_files = vec ! [
150
- RdFile {
151
- name: Some ( "data1" . to_string( ) ) ,
152
- doc_type: Some ( RdDocType :: Data ) ,
153
- } ,
154
- RdFile {
155
- name: Some ( "pkgdoc" . to_string( ) ) ,
156
- doc_type: Some ( RdDocType :: Package ) ,
157
- } ,
158
- RdFile {
159
- name: Some ( "other" . to_string( ) ) ,
160
- doc_type: None ,
161
- } ,
162
- ] ;
163
- let documentation = Documentation { rd_files } ;
164
-
165
- let description = Description {
166
- name : "mypkg" . to_string ( ) ,
167
- version : "1.0.0" . to_string ( ) ,
168
- depends : vec ! [ ] ,
169
- fields : Default :: default ( ) ,
170
- } ;
171
-
172
- let package = Package :: new (
173
- PathBuf :: from ( "/mock/path" ) ,
174
- description,
175
- namespace,
176
- documentation,
177
- ) ;
178
-
179
- assert ! ( package. exported_symbols. contains( & "foo" . to_string( ) ) ) ;
180
- assert ! ( package. exported_symbols. contains( & "bar" . to_string( ) ) ) ;
181
- assert ! ( package. exported_symbols. contains( & "data1" . to_string( ) ) ) ;
182
-
183
- assert ! ( !package. exported_symbols. contains( & "pkgdoc" . to_string( ) ) ) ;
184
- assert ! ( !package. exported_symbols. contains( & "other" . to_string( ) ) ) ;
185
- }
186
- }
0 commit comments