File tree Expand file tree Collapse file tree 3 files changed +50
-1
lines changed Expand file tree Collapse file tree 3 files changed +50
-1
lines changed Original file line number Diff line number Diff line change 146
146
- Fixed a bug where the compiler would suggest a discouraged project name as an
147
147
alternative to the reserved ` gleam ` name.
148
148
([ Giacomo Cavalieri] ( https://github.com/giacomocavalieri ) )
149
+
150
+ - Fixed a bug where Forgejo source URLs in the HTML documentation could be
151
+ incorrectly structured.
152
+ ([ Louis Pilfold] ( https://github.com/lpil ) )
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ impl SourceLinker {
73
73
let cleaned_host = string_host. trim_end_matches ( '/' ) ;
74
74
Some ( (
75
75
format ! ( "{cleaned_host}/{user}/{repo}/src/tag/{tag}/{path_in_repo}#L" , ) ,
76
- "-" . into ( ) ,
76
+ "-L " . into ( ) ,
77
77
) )
78
78
}
79
79
Repository :: Custom { .. } => None ,
@@ -85,6 +85,7 @@ impl SourceLinker {
85
85
url_pattern,
86
86
}
87
87
}
88
+
88
89
pub fn url ( & self , span : SrcSpan ) -> String {
89
90
match & self . url_pattern {
90
91
Some ( ( base, line_sep) ) => {
Original file line number Diff line number Diff line change @@ -1190,3 +1190,47 @@ pub fn aaaaaaaaaaaaaaaaaaaaaaaaaaaa() -> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa {
1190
1190
NONE
1191
1191
) ;
1192
1192
}
1193
+
1194
+ #[ test]
1195
+ fn forgejo_single_line_definition ( ) {
1196
+ let mut config = PackageConfig :: default ( ) ;
1197
+ let repo = Repository :: Forgejo {
1198
+ host : "https://code.example.org/" . parse :: < Uri > ( ) . unwrap ( ) ,
1199
+ user : "wibble" . into ( ) ,
1200
+ repo : "wobble" . into ( ) ,
1201
+ path : None ,
1202
+ tag_prefix : None ,
1203
+ } ;
1204
+
1205
+ config. name = EcoString :: from ( "test_project_name" ) ;
1206
+ config. repository = Some ( repo) ;
1207
+
1208
+ let modules = vec ! [ ( "app.gleam" , "pub type Wibble = Int" ) ] ;
1209
+ let html = compile ( config, modules) ;
1210
+
1211
+ assert ! (
1212
+ html. contains( "https://code.example.org/wibble/wobble/src/tag/v0.1.0/src/app.gleam#L1" )
1213
+ ) ;
1214
+ }
1215
+
1216
+ #[ test]
1217
+ fn forgejo_multiple_line_definition ( ) {
1218
+ let mut config = PackageConfig :: default ( ) ;
1219
+ let repo = Repository :: Forgejo {
1220
+ host : "https://code.example.org/" . parse :: < Uri > ( ) . unwrap ( ) ,
1221
+ user : "wibble" . into ( ) ,
1222
+ repo : "wobble" . into ( ) ,
1223
+ path : None ,
1224
+ tag_prefix : None ,
1225
+ } ;
1226
+
1227
+ config. name = EcoString :: from ( "test_project_name" ) ;
1228
+ config. repository = Some ( repo) ;
1229
+
1230
+ let modules = vec ! [ ( "app.gleam" , "pub type Wibble \n \n = Int" ) ] ;
1231
+ let html = compile ( config, modules) ;
1232
+
1233
+ assert ! (
1234
+ html. contains( "https://code.example.org/wibble/wobble/src/tag/v0.1.0/src/app.gleam#L1-L3" )
1235
+ ) ;
1236
+ }
You can’t perform that action at this time.
0 commit comments