Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

Address review comments

+182 -31
+6 -5
CHANGELOG.md
··· 213 213 deprecated environment variables. 214 214 ([Surya Rose](https://github.com/GearsDatapacks)) 215 215 216 - - When generating documentation, the build tool now prints correct type variable 217 - names for function signatures. For example, this code: 216 + - When generating documentation, the build tool now prints type variable using 217 + the same names as were used in the code for function signatures. For example, 218 + this code: 218 219 219 220 ```gleam 220 - pub fn to_list(list: List(#(key, value))) -> Dict(key, value) { 221 + pub fn to_list(entries: List(#(key, value))) -> Dict(key, value) { 221 222 ... 222 223 } 223 224 ``` ··· 225 226 Previously would have been printed as: 226 227 227 228 ```gleam 228 - pub fn to_list(list: List(#(a, b))) -> Dict(a, b) 229 + pub fn to_list(entries: List(#(a, b))) -> Dict(a, b) 229 230 ``` 230 231 231 232 But now is rendered as the following: 232 233 233 234 ```gleam 234 - pub fn to_list(list: List(#(key, value))) -> Dict(key, value) 235 + pub fn to_list(entries: List(#(key, value))) -> Dict(key, value) 235 236 ``` 236 237 237 238 ([Surya Rose](https://github.com/GearsDatapacks))
+11 -5
compiler-core/src/docs/printer.rs
··· 127 127 source_url: source_links.url(*location), 128 128 opaque: *opaque, 129 129 }), 130 - 131 130 Definition::TypeAlias(TypeAlias { 132 131 publicity: Publicity::Public, 133 132 location, ··· 150 149 }, 151 150 opaque: false, 152 151 }), 153 - 154 - _ => None, 152 + Definition::TypeAlias(_) 153 + | Definition::CustomType(_) 154 + | Definition::Function(_) 155 + | Definition::Import(_) 156 + | Definition::ModuleConstant(_) => None, 155 157 } 156 158 } 157 159 ··· 208 210 }, 209 211 }), 210 212 211 - _ => None, 213 + Definition::TypeAlias(_) 214 + | Definition::CustomType(_) 215 + | Definition::Function(_) 216 + | Definition::Import(_) 217 + | Definition::ModuleConstant(_) => None, 212 218 } 213 219 } 214 220 ··· 436 442 437 443 loop { 438 444 n = rest % alphabet_length; 439 - rest /= alphabet_length; 445 + rest = rest / alphabet_length; 440 446 chars.push((n as u8 + char_offset) as char); 441 447 442 448 if rest == 0 {
+2 -2
compiler-core/src/docs/snapshots/gleam_core__docs__tests__canonical_link.snap
··· 598 598 599 599 </div> 600 600 601 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre> 601 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre> 602 602 603 603 <div class="rendered-markdown"><p>Here is some documentation</p> 604 604 </div> ··· 965 965 966 966 </div> 967 967 968 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre> 968 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre> 969 969 970 970 <div class="rendered-markdown"><p>Here is some documentation</p> 971 971 </div>
+1 -1
compiler-core/src/docs/snapshots/gleam_core__docs__tests__discarded_arguments_are_not_shown.snap
··· 264 264 265 265 </div> 266 266 267 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">discard</span>(<span class="hljs-variable">discarded</span>: <span class="hljs-variable">a</span>) -> <span class="hljs-title">Int</span></code></pre> 267 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">discard</span>(<span class="hljs-variable">discarded</span>: <span class="hljs-variable">a</span>) -> <span class="hljs-title">Int</span></code></pre> 268 268 269 269 <div class="rendered-markdown"></div> 270 270 </div>
+3 -3
compiler-core/src/docs/snapshots/gleam_core__docs__tests__docs_of_a_type_constructor_are_not_used_by_the_following_function.snap
··· 272 272 273 273 <div class="custom-type-constructors"> 274 274 <div class="rendered-markdown"></div> 275 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub type </span><span class="hljs-title">Wibble</span> { 275 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub type </span><span class="hljs-title">Wibble</span> { 276 276 <span class="hljs-title">Wobble</span>(<span class="hljs-variable">wabble</span>: <span class="hljs-title">Int</span>) 277 277 }</code></pre> 278 278 ··· 284 284 <li class="constructor-item"> 285 285 <div class="constructor-row"> 286 286 <svg class="icon icon-star"><use xlink:href="#icon-star"></use></svg> 287 - <pre class="constructor-name"><code class="hljs gleam hljs-ignore"><span class="hljs-title">Wobble</span>(<span class="hljs-variable">wabble</span>: <span class="hljs-title">Int</span>)</code></pre> 287 + <pre class="constructor-name"><code class="hljs hljs-ignore"><span class="hljs-title">Wobble</span>(<span class="hljs-variable">wabble</span>: <span class="hljs-title">Int</span>)</code></pre> 288 288 </div> 289 289 290 290 <div class="constructor-item-docs"> ··· 335 335 336 336 </div> 337 337 338 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">main</span>() -> <span class="hljs-variable">a</span></code></pre> 338 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">main</span>() -> <span class="hljs-variable">a</span></code></pre> 339 339 340 340 <div class="rendered-markdown"></div> 341 341 </div>
+8
compiler-core/src/docs/snapshots/gleam_core__docs__tests__generated_type_variables.snap
··· 2 2 source: compiler-core/src/docs/tests.rs 3 3 expression: output 4 4 --- 5 + ---- SOURCE CODE 6 + -- main.gleam 7 + 8 + pub fn wibble(_a, _b, _c, _d) { 9 + todo 10 + } 11 + 12 + 5 13 ---- VALUES 6 14 7 15 --- wibble
+10
compiler-core/src/docs/snapshots/gleam_core__docs__tests__generated_type_variables_do_not_take_into_account_other_definitions.snap
··· 2 2 source: compiler-core/src/docs/tests.rs 3 3 expression: output 4 4 --- 5 + ---- SOURCE CODE 6 + -- main.gleam 7 + 8 + pub fn wibble(_a: a, _b: b, _c: c) -> d { 9 + todo 10 + } 11 + 12 + pub fn identity(x) { x } 13 + 14 + 5 15 ---- VALUES 6 16 7 17 --- identity
+8
compiler-core/src/docs/snapshots/gleam_core__docs__tests__generated_type_variables_mixed_with_existing_variables.snap
··· 2 2 source: compiler-core/src/docs/tests.rs 3 3 expression: output 4 4 --- 5 + ---- SOURCE CODE 6 + -- main.gleam 7 + 8 + pub fn wibble(_a: b, _b: a, _c, _d) { 9 + todo 10 + } 11 + 12 + 5 13 ---- VALUES 6 14 7 15 --- wibble
+8
compiler-core/src/docs/snapshots/gleam_core__docs__tests__generated_type_variables_with_existing_variables_coming_afterwards.snap
··· 2 2 source: compiler-core/src/docs/tests.rs 3 3 expression: output 4 4 --- 5 + ---- SOURCE CODE 6 + -- main.gleam 7 + 8 + pub fn wibble(_a, _b, _c: b, _d: a) { 9 + todo 10 + } 11 + 12 + 5 13 ---- VALUES 6 14 7 15 --- wibble
+1 -1
compiler-core/src/docs/snapshots/gleam_core__docs__tests__hello_docs.snap
··· 264 264 265 265 </div> 266 266 267 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre> 267 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre> 268 268 269 269 <div class="rendered-markdown"><p>Here is some documentation</p> 270 270 </div>
+6
compiler-core/src/docs/snapshots/gleam_core__docs__tests__highlight_constant_definition.snap
··· 2 2 source: compiler-core/src/docs/tests.rs 3 3 expression: output 4 4 --- 5 + ---- SOURCE CODE 6 + -- main.gleam 7 + 8 + pub const x = 22 9 + 10 + 5 11 ---- VALUES 6 12 7 13 --- x
+9
compiler-core/src/docs/snapshots/gleam_core__docs__tests__highlight_custom_type.snap
··· 2 2 source: compiler-core/src/docs/tests.rs 3 3 expression: output 4 4 --- 5 + ---- SOURCE CODE 6 + -- main.gleam 7 + 8 + pub type Wibble(a, b) { 9 + Wibble(a, i: Int) 10 + Wobble(b: b, c: String) 11 + } 12 + 13 + 5 14 ---- TYPES 6 15 7 16 --- Wibble
+6
compiler-core/src/docs/snapshots/gleam_core__docs__tests__highlight_function_definition.snap
··· 2 2 source: compiler-core/src/docs/tests.rs 3 3 expression: output 4 4 --- 5 + ---- SOURCE CODE 6 + -- main.gleam 7 + 8 + pub fn wibble(list: List(Int), generic: a, function: fn(a) -> b) -> #(a, b) { todo } 9 + 10 + 5 11 ---- VALUES 6 12 7 13 --- wibble
+9
compiler-core/src/docs/snapshots/gleam_core__docs__tests__highlight_opaque_custom_type.snap
··· 2 2 source: compiler-core/src/docs/tests.rs 3 3 expression: output 4 4 --- 5 + ---- SOURCE CODE 6 + -- main.gleam 7 + 8 + pub opaque type Wibble(a, b) { 9 + Wibble(a, i: Int) 10 + Wobble(b: b, c: String) 11 + } 12 + 13 + 5 14 ---- TYPES 6 15 7 16 --- Wibble
+6
compiler-core/src/docs/snapshots/gleam_core__docs__tests__highlight_type_alias.snap
··· 2 2 source: compiler-core/src/docs/tests.rs 3 3 expression: output 4 4 --- 5 + ---- SOURCE CODE 6 + -- main.gleam 7 + 8 + pub type Option(a) = Result(a, Nil) 9 + 10 + 5 11 ---- TYPES 6 12 7 13 --- Option
+1 -1
compiler-core/src/docs/snapshots/gleam_core__docs__tests__ignored_argument_is_called_arg.snap
··· 264 264 265 265 </div> 266 266 267 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>(<span class="hljs-variable">arg</span>: <span class="hljs-variable">a</span>) -> <span class="hljs-title">Int</span></code></pre> 267 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>(<span class="hljs-variable">arg</span>: <span class="hljs-variable">a</span>) -> <span class="hljs-title">Int</span></code></pre> 268 268 269 269 <div class="rendered-markdown"></div> 270 270 </div>
+4 -4
compiler-core/src/docs/snapshots/gleam_core__docs__tests__long_function_wrapping.snap
··· 272 272 273 273 <div class="custom-type-constructors"> 274 274 <div class="rendered-markdown"></div> 275 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub type </span><span class="hljs-title">Option</span>(<span class="hljs-variable">t</span>) { 275 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub type </span><span class="hljs-title">Option</span>(<span class="hljs-variable">t</span>) { 276 276 <span class="hljs-title">Some</span>(<span class="hljs-variable">t</span>) 277 277 <span class="hljs-title">None</span> 278 278 }</code></pre> ··· 285 285 <li class="constructor-item"> 286 286 <div class="constructor-row"> 287 287 <svg class="icon icon-star"><use xlink:href="#icon-star"></use></svg> 288 - <pre class="constructor-name"><code class="hljs gleam hljs-ignore"><span class="hljs-title">Some</span>(<span class="hljs-variable">t</span>)</code></pre> 288 + <pre class="constructor-name"><code class="hljs hljs-ignore"><span class="hljs-title">Some</span>(<span class="hljs-variable">t</span>)</code></pre> 289 289 </div> 290 290 291 291 <div class="constructor-item-docs"> ··· 298 298 <li class="constructor-item"> 299 299 <div class="constructor-row"> 300 300 <svg class="icon icon-star"><use xlink:href="#icon-star"></use></svg> 301 - <pre class="constructor-name"><code class="hljs gleam hljs-ignore"><span class="hljs-title">None</span></code></pre> 301 + <pre class="constructor-name"><code class="hljs hljs-ignore"><span class="hljs-title">None</span></code></pre> 302 302 </div> 303 303 304 304 <div class="constructor-item-docs"> ··· 333 333 334 334 </div> 335 335 336 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">lazy_or</span>( 336 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">lazy_or</span>( 337 337 <span class="hljs-variable">first</span>: <a href="#Option"><span class="hljs-title">Option</span></a>(<span class="hljs-variable">a</span>), 338 338 <span class="hljs-variable">second</span>: <span class="hljs-keyword">fn</span>() -> <a href="#Option"><span class="hljs-title">Option</span></a>(<span class="hljs-variable">a</span>), 339 339 ) -> <a href="#Option"><span class="hljs-title">Option</span></a>(<span class="hljs-variable">a</span>)</code></pre>
+1 -1
compiler-core/src/docs/snapshots/gleam_core__docs__tests__markdown_code_from_function_comment_is_trimmed.snap
··· 264 264 265 265 </div> 266 266 267 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">indentation_test</span>() -> <span class="hljs-variable">a</span></code></pre> 267 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">indentation_test</span>() -> <span class="hljs-variable">a</span></code></pre> 268 268 269 269 <div class="rendered-markdown"><p>Here’s an example code snippet:</p> 270 270 <pre><code>wibble
+2 -2
compiler-core/src/docs/snapshots/gleam_core__docs__tests__no_hex_publish.snap
··· 584 584 585 585 </div> 586 586 587 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre> 587 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre> 588 588 589 589 <div class="rendered-markdown"><p>Here is some documentation</p> 590 590 </div> ··· 944 944 945 945 </div> 946 946 947 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre> 947 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre> 948 948 949 949 <div class="rendered-markdown"><p>Here is some documentation</p> 950 950 </div>
+21
compiler-core/src/docs/snapshots/gleam_core__docs__tests__print_qualified_names_from_other_modules.snap
··· 2 2 source: compiler-core/src/docs/tests.rs 3 3 expression: output 4 4 --- 5 + ---- SOURCE CODE 6 + -- gleam/option.gleam 7 + 8 + pub type Option(t) { 9 + Some(t) 10 + None 11 + } 12 + 13 + 14 + -- main.gleam 15 + 16 + import gleam/option.{type Option, Some, None} 17 + 18 + pub fn from_option(o: Option(t), e: e) -> Result(t, e) { 19 + case o { 20 + Some(t) -> Ok(t) 21 + None -> Error(e) 22 + } 23 + } 24 + 25 + 5 26 ---- VALUES 6 27 7 28 --- from_option
+10
compiler-core/src/docs/snapshots/gleam_core__docs__tests__print_type_variables_in_function_signatures.snap
··· 2 2 source: compiler-core/src/docs/tests.rs 3 3 expression: output 4 4 --- 5 + ---- SOURCE CODE 6 + -- main.gleam 7 + 8 + pub type Dict(key, value) 9 + 10 + pub fn insert(dict: Dict(key, value), key: key, value: value) -> Dict(key, value) { 11 + dict 12 + } 13 + 14 + 5 15 ---- TYPES 6 16 7 17 --- Dict
+1 -1
compiler-core/src/docs/snapshots/gleam_core__docs__tests__tables.snap
··· 264 264 265 265 </div> 266 266 267 - <pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre> 267 + <pre><code class="hljs hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre> 268 268 269 269 <div class="rendered-markdown"><table><thead><tr><th>heading 1</th><th>heading 2</th></tr></thead><tbody> 270 270 <tr><td>row 1 cell 1</td><td>row 1 cell 2</td></tr>
+9 -2
compiler-core/src/docs/tests.rs
··· 137 137 modules: Vec<(&str, &str, &str)>, 138 138 options: PrintOptions, 139 139 ) -> EcoString { 140 - let module = type_::tests::compile_module("main", main_module, None, modules) 140 + let module = type_::tests::compile_module("main", main_module, None, modules.clone()) 141 141 .expect("Module should compile successfully"); 142 142 143 143 let mut config = PackageConfig::default(); ··· 181 181 182 182 let mut output = EcoString::new(); 183 183 184 + output.push_str("---- SOURCE CODE\n"); 185 + for (_package, name, src) in modules { 186 + output.push_str(&format!("-- {name}.gleam\n{src}\n\n")); 187 + } 188 + output.push_str("-- main.gleam\n"); 189 + output.push_str(main_module); 190 + 184 191 if !types.is_empty() { 185 - output.push_str("---- TYPES"); 192 + output.push_str("\n\n---- TYPES"); 186 193 } 187 194 for type_ in types { 188 195 output.push_str("\n\n--- ");
+3 -3
compiler-core/templates/documentation_module.html
··· 55 55 {% endif %} 56 56 <div class="custom-type-constructors"> 57 57 <div class="rendered-markdown">{{ typ.documentation|safe }}</div> 58 - <pre><code class="hljs gleam hljs-ignore">{{ typ.definition|safe }}</code></pre> 58 + <pre><code class="hljs hljs-ignore">{{ typ.definition|safe }}</code></pre> 59 59 {% if !typ.constructors.is_empty() %} 60 60 <h3> 61 61 Constructors ··· 65 65 <li class="constructor-item"> 66 66 <div class="constructor-row"> 67 67 <svg class="icon icon-star"><use xlink:href="#icon-star"></use></svg> 68 - <pre class="constructor-name"><code class="hljs gleam hljs-ignore">{{ constructor.definition|safe }}</code></pre> 68 + <pre class="constructor-name"><code class="hljs hljs-ignore">{{ constructor.definition|safe }}</code></pre> 69 69 </div> 70 70 71 71 <div class="constructor-item-docs"> ··· 119 119 {% endif %} 120 120 </div> 121 121 122 - <pre><code class="hljs gleam hljs-ignore">{{ value.definition|safe }}</code></pre> 122 + <pre><code class="hljs hljs-ignore">{{ value.definition|safe }}</code></pre> 123 123 {% if !value.deprecation_message.is_empty() %} 124 124 <p> 125 125 <b>Deprecated:</b> {{ value.deprecation_message }}