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

Configure Feed

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

Fix a bug with test code

+780 -21
+2 -1
compiler-cli/src/docs.rs
··· 2 2 3 3 use camino::{Utf8Path, Utf8PathBuf}; 4 4 5 - use crate::{cli, hex::ApiKeyCommand, http::HttpClient}; 5 + use crate::{cli, fs::ProjectIO, hex::ApiKeyCommand, http::HttpClient}; 6 6 use gleam_core::{ 7 7 analyse::TargetSupport, 8 8 build::{Codegen, Mode, Options, Package}, ··· 129 129 config, 130 130 compiled.modules.as_slice(), 131 131 &pages, 132 + ProjectIO::new(), 132 133 SystemTime::now(), 133 134 ); 134 135
+4 -3
compiler-core/src/docs.rs
··· 14 14 config::{DocsPage, PackageConfig}, 15 15 docs::source_links::SourceLinker, 16 16 format, 17 - io::{Content, OutputFile}, 17 + io::{Content, FileSystemReader, OutputFile}, 18 18 package_interface::PackageInterface, 19 19 paths::ProjectPaths, 20 20 pretty, ··· 29 29 30 30 const MAX_COLUMNS: isize = 65; 31 31 32 - pub fn generate_html( 32 + pub fn generate_html<IO: FileSystemReader>( 33 33 paths: &ProjectPaths, 34 34 config: &PackageConfig, 35 35 analysed: &[Module], 36 36 docs_pages: &[DocsPage], 37 + fs: IO, 37 38 rendering_timestamp: SystemTime, 38 39 ) -> Vec<OutputFile> { 39 40 let modules = analysed ··· 91 92 92 93 // Generate user-supplied (or README) pages 93 94 for page in docs_pages { 94 - let content = std::fs::read_to_string(&page.source).unwrap_or_default(); 95 + let content = fs.read(&page.source).unwrap_or_default(); 95 96 let rendered_content = render_markdown(&content, MarkdownSource::Standalone); 96 97 let unnest = page_unnest(&page.path); 97 98
+361
compiler-core/src/docs/snapshots/gleam_core__docs__tests__markdown_code_from_function_comment_is_trimmed.snap
··· 1 + --- 2 + source: compiler-core/src/docs/tests.rs 3 + expression: "compile(config, modules)" 4 + --- 5 + //// app.html 6 + 7 + <!DOCTYPE html> 8 + <html> 9 + <head> 10 + <meta charset="utf-8"/> 11 + <meta name="viewport" content="width=device-width, initial-scale=1"/> 12 + <title>app · · v0.1.0</title> 13 + <meta name="description" content=""/> 14 + <meta name="theme-color" content="#ffaff3" media="(prefers-color-scheme: light)"/> 15 + <meta name="theme-color" content="#33384d" media="(prefers-color-scheme: dark)"/> 16 + <link rel="stylesheet" href="./css/index.css?v=GLEAM_VERSION_HERE" type="text/css"/> 17 + <!-- The docs_config.js file is provided by HexDocs and shared 18 + between multiple versions of the same package. --> 19 + <script src="./docs_config.js"></script> 20 + <link id="syntax-theme" rel="stylesheet" href="./css/atom-one-light.min.css?v=GLEAM_VERSION_HERE"/> 21 + </head> 22 + <body class="prewrap-off theme-light drawer-closed"> 23 + <script> 24 + "use strict"; 25 + 26 + /* gleamConfig format: 27 + * // object with one or more options 28 + * {option: { 29 + * // array of values 30 + * values: [{ 31 + * // this value 32 + * value: "off", 33 + * // optional button label 34 + * label: "default", 35 + * // optional array of icons 36 + * icons: ["star", "toggle-left", ...], 37 + * }, ...], 38 + * 39 + * // value update function 40 + * update: () => {...}, 41 + * 42 + * // optional callback function 43 + * callback: (value) => {...}, 44 + * }, ...}; 45 + */ 46 + window.unnest = '.'; 47 + const gleamConfig = { 48 + theme: { 49 + values: (() => { 50 + const dark = { 51 + value: "dark", 52 + label: "Switch to light mode", 53 + icons: ["moon"], 54 + }; 55 + const light = { 56 + value: "light", 57 + label: "Switch to dark mode", 58 + icons: ["sun"], 59 + }; 60 + return ( 61 + window.matchMedia("(prefers-color-scheme: dark)").matches 62 + ? [dark, light] 63 + : [light, dark] 64 + ).map((item, index) => { 65 + item.icons.push(`toggle-${0 === index ? "left" : "right"}`); 66 + return item; 67 + }); 68 + })(), 69 + 70 + update: () => "light" === Gleam.getProperty("theme") ? "dark" : "light", 71 + 72 + callback: function(value) { 73 + const syntaxThemes = { 74 + dark: "atom-one-dark", 75 + light: "atom-one-light", 76 + }; 77 + const syntaxTheme = document.querySelector("#syntax-theme"); 78 + const hrefParts = syntaxTheme.href.match( 79 + /^(.*?)([^/\\#?]+?)((?:\.min)?\.css.*)$/i 80 + ); 81 + if (syntaxThemes[value] !== hrefParts[2]) { 82 + hrefParts[2] = syntaxThemes[value]; 83 + hrefParts.shift(); 84 + syntaxTheme.href = hrefParts.join(""); 85 + } 86 + }, 87 + }, 88 + prewrap: { 89 + values: [ 90 + { 91 + value: "off", 92 + label: "Switch to line-wrapped snippets", 93 + icons: ["more-horizontal", "toggle-left"], 94 + }, 95 + { 96 + value: "on", 97 + label: "Switch to non-wrapped snippets", 98 + icons: ["more-vertical", "toggle-right"], 99 + }, 100 + ], 101 + 102 + update: () => "off" === Gleam.getProperty("prewrap") ? "on" : "off", 103 + }, 104 + }; 105 + </script> 106 + 107 + <script> 108 + "use strict"; 109 + 110 + /* Initialise options before any content loads */ 111 + void function() { 112 + for (const property in gleamConfig) { 113 + const name = `Gleam.${property}`; 114 + 115 + let value; 116 + 117 + try { 118 + value = localStorage.getItem(name); 119 + if (value.startsWith('"') && value.endsWith('"')) { 120 + localStorage.setItem(name, value.slice(1, value.length - 1)); 121 + } 122 + } 123 + catch (_error) {} 124 + 125 + const defaultValue = gleamConfig[property].values[0].value; 126 + try { 127 + value = localStorage.getItem(name); 128 + } 129 + catch(_error) {} 130 + if (-1 < [null, undefined].indexOf(value)) { 131 + value = defaultValue; 132 + } 133 + const bodyClasses = document.body.classList; 134 + bodyClasses.remove(`${property}-${defaultValue}`); 135 + bodyClasses.add(`${property}-${value}`); 136 + try { 137 + gleamConfig[property].callback(value); 138 + } 139 + catch(_error) {} 140 + } 141 + }(); 142 + </script> 143 + 144 + <header class="page-header"> 145 + <button class="sidebar-toggle" tabindex="0"> 146 + <svg class="label label-closed icon icon-menu" alt="Open Menu" title="Open Menu"><use xlink:href="#icon-menu"></use></svg> 147 + <svg class="label label-open icon icon-x-circle" alt="Close Menu" title="Close Menu"><use xlink:href="#icon-x-circle"></use></svg> 148 + </button> 149 + 150 + <h2> 151 + <a href="./"></a> 152 + <span id="project-version"> 153 + <span> - v0.1.0 </span> 154 + </span> 155 + <script> 156 + "use strict"; 157 + 158 + if ("undefined" !== typeof versionNodes) { 159 + const currentVersion = "v0.1.0"; 160 + if (! versionNodes.find(element => element.version === currentVersion)) { 161 + versionNodes.unshift({ version: currentVersion, url: "#" }); 162 + } 163 + document.querySelector("#project-version").innerHTML = 164 + versionNodes.reduce( 165 + (acc, element) => { 166 + const status = 167 + currentVersion === element.version ? "selected disabled" : ""; 168 + return ` 169 + ${acc} 170 + <option value="${element.url}" ${status}> 171 + ${element.version} 172 + </option> 173 + `; 174 + }, 175 + ` 176 + <form autocomplete="off"> 177 + <select onchange="window.location.href = this.value"> 178 + ` 179 + ) + ` 180 + </select> 181 + <svg class="icon icon-chevrons-down"><use xlink:href="#icon-chevrons-down"></use></svg> 182 + </form> 183 + `; 184 + } 185 + </script> 186 + </h2> 187 + <div class="search"> 188 + <div class="search-input-wrap"> 189 + <input type="text" id="search-input" class="search-input" tabindex="0" aria-label="Search " autocomplete="off"> 190 + <label for="search-input" class="search-label"><svg viewBox="0 0 24 24" class="search-icon"><use xlink:href="#icon-svg-search"></use></svg></label> 191 + </div> 192 + <div id="search-results" class="search-results"></div> 193 + </div> 194 + 195 + <button class="search-nav-button" id="search-nav-button" tabindex="0"> 196 + <svg class="label icon icon-x-circle" alt="Open Search" title="Open Search"><use xlink:href="#icon-svg-search"></use></svg> 197 + </button> 198 + 199 + </header> 200 + 201 + <div class="page"> 202 + <nav class="sidebar"> 203 + <button class="sidebar-toggle" tabindex="1"> 204 + <svg class="label icon icon-x-circle" alt="Close Menu" title="Close Menu"><use xlink:href="#icon-x-circle"></use></svg> 205 + </button> 206 + 207 + 208 + 209 + 210 + <h2>Links</h2> 211 + <ul> 212 + 213 + <li><a href="https://hex.pm/packages/">Hex</a></li> 214 + 215 + </ul> 216 + 217 + 218 + <h2>Modules</h2> 219 + <ul> 220 + 221 + <li><a href="./app.html">app</a></li> 222 + 223 + </ul> 224 + 225 + 226 + 227 + 228 + 229 + 230 + 231 + <h2>Functions</h2> 232 + <ul> 233 + 234 + <li><a href="#indentation_test">indentation_test</a></li> 235 + 236 + </ul> 237 + 238 + 239 + </nav> 240 + 241 + <main class="content"> 242 + 243 + <h1 id="module-name" class="module-name"> 244 + <a href="#module-name">app</a> 245 + <svg class="icon icon-gleam-chasse"><use xlink:href="#icon-gleam-chasse"></use></svg> 246 + </h1> 247 + 248 + 249 + 250 + 251 + 252 + 253 + 254 + <section class="module-members"> 255 + <h1 id="module-functions" class="module-member-kind"> 256 + <a href="#module-functions">Functions</a> 257 + <svg class="icon icon-gleam-chasse"><use xlink:href="#icon-gleam-chasse"></use></svg> 258 + </h1> 259 + 260 + <div class="member"> 261 + <div class="member-name"> 262 + <h2 id="indentation_test"> 263 + <a href="#indentation_test"> 264 + indentation_test 265 + </a> 266 + </h2> 267 + 268 + </div> 269 + 270 + <pre><code class="hljs gleam">pub fn indentation_test() -&gt; a</code></pre> 271 + 272 + <div class="rendered-markdown"><p>Here’s an example code snippet:</p> 273 + <pre><code>wibble 274 + |&gt; wobble 275 + </code></pre> 276 + </div> 277 + </div> 278 + 279 + </section> 280 + 281 + 282 + </main> 283 + <div class="search-overlay"></div> 284 + </div> 285 + 286 + <script> 287 + "use strict"; 288 + const pride = () => document.body.classList.toggle("show-pride"); 289 + </script> 290 + <a class="pride-button" onclick="pride()">✨</a> 291 + <footer class="pride" onclick="pride()"> 292 + <div class="blue">Lucy</div> 293 + <div class="pink">says</div> 294 + <div class="white">trans</div> 295 + <div class="pink">rights</div> 296 + <div class="blue">now</div> 297 + </footer> 298 + 299 + <svg class="svg-lib" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> 300 + <defs> 301 + <symbol id="icon-chevrons-down" viewBox="0 0 24 24"><path d="M6.293 13.707l5 5c0.391 0.391 1.024 0.391 1.414 0l5-5c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-4.293 4.293-4.293-4.293c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414zM6.293 6.707l5 5c0.391 0.391 1.024 0.391 1.414 0l5-5c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-4.293 4.293-4.293-4.293c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414z"></path></symbol> 302 + 303 + <symbol id="icon-gleam-chasse" viewBox="0 0 180 22"><path d="m0.00798 15.6c0.784-1.73 0.754-2.11 1.94-3.97 1.17-0.28 2.66-0.119 3.71-0.524 1.12 0.501 1.85 0.729 3.35-0.466 0.942-0.806 2.41 0.656 3.41-0.0865 2.53-1.48 0.972-1.03 5.14-0.585 1.79-0.493 3.46-0.852 6.64-1.06 3.8-0.331 0.0108-1.06 5.16-1.16 0.874-0.835 3.43-1.34 5.49-0.963 2.17-1.41 0.488-1.58 2.64-0.426 4.36-0.0592 0.83-1.08 5.39-1.22 3.27-0.264 0.843-0.471 2.82 0.187 2.13-0.254 1.36-0.525 3.67 0.709 1.77 1.66 0.962 0.181 1.9 2.32 0.26 0.593 0.304 1.71 0.814 1.74 3.67-0.833-0.0875 0.536 4.63-0.838 0.719-0.891 4.42 0.255 3.8-0.806 2.07 0.119 2.75-0.7 6.07-0.822 1.48-1.17 2.26 0.943 3.4-0.974 0.391 0.166-1.61-0.548 3.88-0.154 2.93-1.26-1.74 0.103 4.21-0.851 3.52 8e-3 0.233-0.263 3.33-0.811 1.06-1.46-0.459-1.02 5.55-0.963 2.61-2.11 0.281-1.59 4.88-0.572 0.699 0.597 3.05 1.65 3.99 3.26 0.863-0.152 2.77 0.0659 3.41-0.626 2.24-1.04-0.0635-1.05 3.37-1.34 2.1 0.115 2.2-1.21 2.77-0.679 5.91-0.778 1.96-1.63 4.89-1.49 5.47 0.212 0.204 1.22 3.99-0.265 2.14-0.0482 0.411-0.776 2.93-0.892 2.17-0.148 0.604-0.262 2.54-1.52 0.804 0.0911 1.11 0.562 1.23 1.57 0.468 1.54 0.966 3.31 1.86 4.62 2.67-0.472-0.76-0.582 4.72-0.393 3.14 0.131 3.72-0.565 6.16-0.724 4.54-0.853 1.37-0.939 5.89-0.58 10.1-1.7 2.9-0.523 10.2-1.15 4.86-0.211 4.69-0.969 7.4-1.04 3.46-0.0576 3.13 0.58 3.83 0 3.63 0.257 2.5-0.141 7.74-0.46 2.23 1.09-0.13 0.518 5.9 0.145 1.12-0.0184 2.85-6e-3 3.83-0.186 0.748 0.694 1.01 1.4 1.58 2.33-0.112 0.687-0.306 0.992-0.454 1.51 0.0805 0.459-0.0486 0.901 0.226 1.36 0.057 0.859-1.34 1.08-2.69 0.127-3.53-0.828-1.21-0.849-7.23 0.974-5.16-0.286-1.66-0.354-7.64 0.321-1.48 0.961-4.73 0.287-6.76 0.551-4.01 0.178-1.95-0.517-3.33 0.624-5.29 1.8-3.12 1.47-5.66 0.941-5.26 0.0339-2.08-0.772-4.75 0.424-6.08 2.5-3.35 1.33-7.54 2.02-6.37-0.269-3.02 1.17-6.76 0.468-0.975 0.1-2.43 0.343-3.46 0.786-1.5-0.748-1.92 0.689-3.38 0.363-0.83-0.0851-2.1-0.343-3.5-0.0239-1.28 0.81-3.87-0.666-5.67-2.17-0.131-0.478-0.106-0.902-0.403-1.69-1.63 0.392-0.668 0.395-4.29 1.14-2.71 0.289 0.131 0.495-3.22 0.964-0.638 0.331-0.998 1.17-3.15 1.04-3.09 0.469-4.48 2.1-3.66 0.577-2.95 0.347-2.9 1.82-5.86 1.85-3.3 0.815 0.192 0.978-5.2 1.66-2.81 2.66 0.0387 0.735-4.21 1.29-1.43-0.911-2.24-2.29-3.89-3.63-0.363-0.679 0.258-1.84-0.375-2.28-5.28 1.39 0.176-0.925-5.08 1.01-10.6 1.42-4.55 1.88-9.18 1.66-6.73 1.35-4.11 1.99-10.2 2.31-4.53 1.09-1.63-0.398-5.52 1.02-3.15 0.522-2.41-0.0562-4.51 1.04-0.76 0.379-0.865-0.416-2.75-0.0493-3.5-3.45-2.85-0.892-2.93-6.14-4.41 0.837 0.477 0.703-6.18 1.2-4.59 0.0171-1.93 1.02-7.41 1.04-0.815 0.505-2.55 0.453-4.13 0.791-5 0.71-5.97 2-8.46 1.61-1.39 1.09-2.58 1.53-4.22 2.62-0.919 0.756-3.45 0.596-4.48 0.492-0.525-0.406-0.751-1.2-1.82-3.28 0.149-0.902-0.325-1.44-0.248-2.8z"></path></symbol> 304 + 305 + <symbol id="icon-gleam-chasse-2" viewBox="0 0 108 22"><path d="m0.585 18.5c-0.578-1.54-0.65-1.33-0.543-2.64 0.271-1.19 0.153-1.06 1.27-1.71 0.993 0.124 1.94-0.662 2.94-0.869 2.48 0.119 0.772 0.443 2.99-0.366 1.66-1.91 0.764 0.783 3.36-0.992 2.37 0.314 4.26-1.5 5.16-1.26 0.387 0.627 0.202 0.412 2.52-0.776 4.89-1.57 3.91-1.47 5-0.972 2.05-1.09-0.0615-0.49 2.79-1.2 4.47-0.514 3.62 0.127 4.18-1.19 4.3-0.613 2.56-1.49 4.09-0.847 1.8-1.51 1.01 0.157 2.64-0.722 4.91-1.28 1.39 0.553 4.43-0.843 1.28-0.387 2.72-0.427 4.05-0.748 0.332-0.942 1.93 0.121 2.75-0.817 3 0.294-0.74-0.514 3.35-0.219 2.34-1.12 0.474 0.505 3.01-1.33 0.779-0.552 0.958 0.919 2.76-0.331 1.26-0.027 0.231 0.642 1.71 0.0417 1.08-0.234-0.332-0.25 1.4-0.727 1.07 0.281 0.347 0.858 2.47 1.86 1.02 2.09-0.0407 0.967 0.473 3.88-0.19 1.31 0.095 0.629-1.34 1.44-0.351 0.381-0.494 0.132-0.0505 0.773 5.7-0.865 2.24-0.0704 4.31-0.722 1.39-0.602 3.12 0.189 3.85-0.396 5.52-1.74 1.2 0.802 5.56-0.972 5.77-0.78 5.5-0.0267 5.87-0.622 1.29-0.593 0.466-0.184 2.73-0.0872 0.586-0.907-0.0863-0.919 1.23-0.644 0.471-1.23 3.03 0.227 3.86-0.234 1.2 0.319 2.27 0.00513 2.55 0.264 0.378 0.998 1.18 1.79 1.78 2.57-0.109 0.798 0.472 1.14 0.254 2.4 2.25-0.43 1.69-0.298 4.1-0.338 2.35-1.11 0.595 0.263 3.12-0.813 1.5-0.153 2.17 0.044 3.29-0.328 1.39-0.699 0.859-0.135 1.88-0.671 1.35 0.779 0.389 0.64 1.39 1.7 0.132 1.37 0.34 1.03 0.117 2.21-0.619 0.327-0.757 0.0587-1.28 0.739-2.68 0.688-0.161 0.395-2.5 0.734-1.97-0.203-0.915-0.0737-3.21 0.454-1.76 1.41-0.982 1.12-2.36 1.43-1.65 0.974 0.119-0.784-2.27 0.501-0.883 0.361-1.2 0.471-1.88 0.827-2.84 1.1-1.72-0.0496-3.18 1.37-2.38 0.689-1.82 0.324-2.65 1.27-3.52 0.658-2.07-0.49-3.27-0.419-1.85-2.19 0.14-0.414-1.87-2.62-0.551-2.06-0.527-0.977 0.131-2.63 0.366-1.44 0.369-0.627 1.15-1.88-1.79 0.433-1.64 0.163-5.6 0.781-3.59 1.82-0.592-0.17-4.29 0.729-0.705 0.598-0.369 0.995-1.59-0.0892-0.655 0.638-0.104 0.42-2.9 0.621-3.6 1.1-2.83 1.29-4.17 0.742 0.0193-1.05-1.8 1.24-2.18 0.454-2.51 0.61-1.36 0.795-3.64 0.594-0.211 0.804-4.14-0.139-5.09 0.879-3.61 0.381 0.127-0.296-3.51-1.03-1.44-1.87-1.14-0.196-1.22-3.01 0.14-1.2-0.505-0.638-0.0251-2.39-2.64 0.466-1.25-0.372-3.55 0.344-4.12 0.781-0.26 1.32-4.36 1.02-1.78 0.235 0.327 0.568-3.16 0.555-1.36 0.861-0.709 0.778-2.01 0.649-4.07 1.1-0.948 0.904-4.54 1.17-1.27 0.686-4.67 0.341-4.6 1.04-2.47 0.466-0.707 1.46-3.49 0.582-2.93 1.39-0.739 1.31-4.38 1.56-3.21 1.23-0.735 1.93-3.87 1.14-2.82 1.91-0.676 1.23-4.04 1.82-1.97 1.47 0.312 0.745-2.95 0.812-3.51 1.54 0.0965-0.473-4.27 1.39-2.68 0.382-1.75 0.682-3.32-0.585-1.65-1.61 0.361-0.307-1.37-2.31z"></path></symbol> 306 + 307 + <symbol id="icon-menu" viewBox="0 0 24 24"><path d="M3 13h18c0.552 0 1-0.448 1-1s-0.448-1-1-1h-18c-0.552 0-1 0.448-1 1s0.448 1 1 1zM3 7h18c0.552 0 1-0.448 1-1s-0.448-1-1-1h-18c-0.552 0-1 0.448-1 1s0.448 1 1 1zM3 19h18c0.552 0 1-0.448 1-1s-0.448-1-1-1h-18c-0.552 0-1 0.448-1 1s0.448 1 1 1z"></path></symbol> 308 + 309 + <symbol id="icon-moon" viewBox="0 0 24 24"><path d="M21.996 12.882c0.022-0.233-0.038-0.476-0.188-0.681-0.325-0.446-0.951-0.544-1.397-0.219-0.95 0.693-2.060 1.086-3.188 1.162-1.368 0.092-2.765-0.283-3.95-1.158-1.333-0.985-2.139-2.415-2.367-3.935s0.124-3.124 1.109-4.456c0.142-0.191 0.216-0.435 0.191-0.691-0.053-0.55-0.542-0.952-1.092-0.898-2.258 0.22-4.314 1.18-5.895 2.651-1.736 1.615-2.902 3.847-3.137 6.386-0.254 2.749 0.631 5.343 2.266 7.311s4.022 3.313 6.772 3.567 5.343-0.631 7.311-2.266 3.313-4.022 3.567-6.772zM19.567 14.674c-0.49 1.363-1.335 2.543-2.416 3.441-1.576 1.309-3.648 2.016-5.848 1.813s-4.108-1.278-5.417-2.854-2.016-3.648-1.813-5.848c0.187-2.032 1.117-3.814 2.507-5.106 0.782-0.728 1.71-1.3 2.731-1.672-0.456 1.264-0.577 2.606-0.384 3.899 0.303 2.023 1.38 3.934 3.156 5.247 1.578 1.167 3.448 1.668 5.272 1.545 0.752-0.050 1.496-0.207 2.21-0.465z"></path></symbol> 310 + 311 + <symbol id="icon-more-horizontal" viewBox="0 0 24 24"><path d="M14 12c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414zM21 12c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414zM7 12c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414z"></path></symbol> 312 + 313 + <symbol id="icon-more-vertical" viewBox="0 0 24 24"><path d="M14 12c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414zM14 5c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414zM14 19c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414z"></path></symbol> 314 + 315 + <symbol id="icon-star" viewBox="0 0 24 24"><path d="M12.897 1.557c-0.092-0.189-0.248-0.352-0.454-0.454-0.495-0.244-1.095-0.041-1.339 0.454l-2.858 5.789-6.391 0.935c-0.208 0.029-0.411 0.127-0.571 0.291-0.386 0.396-0.377 1.029 0.018 1.414l4.623 4.503-1.091 6.362c-0.036 0.207-0.006 0.431 0.101 0.634 0.257 0.489 0.862 0.677 1.351 0.42l5.714-3.005 5.715 3.005c0.186 0.099 0.408 0.139 0.634 0.101 0.544-0.093 0.91-0.61 0.817-1.155l-1.091-6.362 4.623-4.503c0.151-0.146 0.259-0.344 0.292-0.572 0.080-0.546-0.298-1.054-0.845-1.134l-6.39-0.934zM12 4.259l2.193 4.444c0.151 0.305 0.436 0.499 0.752 0.547l4.906 0.717-3.549 3.457c-0.244 0.238-0.341 0.569-0.288 0.885l0.837 4.883-4.386-2.307c-0.301-0.158-0.647-0.148-0.931 0l-4.386 2.307 0.837-4.883c0.058-0.336-0.059-0.661-0.288-0.885l-3.549-3.457 4.907-0.718c0.336-0.049 0.609-0.26 0.752-0.546z"></path></symbol> 316 + 317 + <symbol id="icon-sun" viewBox="0 0 24 24"><path d="M18 12c0-1.657-0.673-3.158-1.757-4.243s-2.586-1.757-4.243-1.757-3.158 0.673-4.243 1.757-1.757 2.586-1.757 4.243 0.673 3.158 1.757 4.243 2.586 1.757 4.243 1.757 3.158-0.673 4.243-1.757 1.757-2.586 1.757-4.243zM16 12c0 1.105-0.447 2.103-1.172 2.828s-1.723 1.172-2.828 1.172-2.103-0.447-2.828-1.172-1.172-1.723-1.172-2.828 0.447-2.103 1.172-2.828 1.723-1.172 2.828-1.172 2.103 0.447 2.828 1.172 1.172 1.723 1.172 2.828zM11 1v2c0 0.552 0.448 1 1 1s1-0.448 1-1v-2c0-0.552-0.448-1-1-1s-1 0.448-1 1zM11 21v2c0 0.552 0.448 1 1 1s1-0.448 1-1v-2c0-0.552-0.448-1-1-1s-1 0.448-1 1zM3.513 4.927l1.42 1.42c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-1.42-1.42c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414zM17.653 19.067l1.42 1.42c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-1.42-1.42c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414zM1 13h2c0.552 0 1-0.448 1-1s-0.448-1-1-1h-2c-0.552 0-1 0.448-1 1s0.448 1 1 1zM21 13h2c0.552 0 1-0.448 1-1s-0.448-1-1-1h-2c-0.552 0-1 0.448-1 1s0.448 1 1 1zM4.927 20.487l1.42-1.42c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-1.42 1.42c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0zM19.067 6.347l1.42-1.42c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-1.42 1.42c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0z"></path></symbol> 318 + 319 + <symbol id="icon-toggle-left" viewBox="0 0 24 24"><path d="M8 4c-2.209 0-4.21 0.897-5.657 2.343s-2.343 3.448-2.343 5.657 0.897 4.21 2.343 5.657 3.448 2.343 5.657 2.343h8c2.209 0 4.21-0.897 5.657-2.343s2.343-3.448 2.343-5.657-0.897-4.21-2.343-5.657-3.448-2.343-5.657-2.343zM8 6h8c1.657 0 3.156 0.67 4.243 1.757s1.757 2.586 1.757 4.243-0.67 3.156-1.757 4.243-2.586 1.757-4.243 1.757h-8c-1.657 0-3.156-0.67-4.243-1.757s-1.757-2.586-1.757-4.243 0.67-3.156 1.757-4.243 2.586-1.757 4.243-1.757zM12 12c0-1.104-0.449-2.106-1.172-2.828s-1.724-1.172-2.828-1.172-2.106 0.449-2.828 1.172-1.172 1.724-1.172 2.828 0.449 2.106 1.172 2.828 1.724 1.172 2.828 1.172 2.106-0.449 2.828-1.172 1.172-1.724 1.172-2.828zM10 12c0 0.553-0.223 1.051-0.586 1.414s-0.861 0.586-1.414 0.586-1.051-0.223-1.414-0.586-0.586-0.861-0.586-1.414 0.223-1.051 0.586-1.414 0.861-0.586 1.414-0.586 1.051 0.223 1.414 0.586 0.586 0.861 0.586 1.414z"></path></symbol> 320 + 321 + <symbol id="icon-toggle-right" viewBox="0 0 24 24"><path d="M8 4c-2.209 0-4.21 0.897-5.657 2.343s-2.343 3.448-2.343 5.657 0.897 4.21 2.343 5.657 3.448 2.343 5.657 2.343h8c2.209 0 4.21-0.897 5.657-2.343s2.343-3.448 2.343-5.657-0.897-4.21-2.343-5.657-3.448-2.343-5.657-2.343zM8 6h8c1.657 0 3.156 0.67 4.243 1.757s1.757 2.586 1.757 4.243-0.67 3.156-1.757 4.243-2.586 1.757-4.243 1.757h-8c-1.657 0-3.156-0.67-4.243-1.757s-1.757-2.586-1.757-4.243 0.67-3.156 1.757-4.243 2.586-1.757 4.243-1.757zM20 12c0-1.104-0.449-2.106-1.172-2.828s-1.724-1.172-2.828-1.172-2.106 0.449-2.828 1.172-1.172 1.724-1.172 2.828 0.449 2.106 1.172 2.828 1.724 1.172 2.828 1.172 2.106-0.449 2.828-1.172 1.172-1.724 1.172-2.828zM18 12c0 0.553-0.223 1.051-0.586 1.414s-0.861 0.586-1.414 0.586-1.051-0.223-1.414-0.586-0.586-0.861-0.586-1.414 0.223-1.051 0.586-1.414 0.861-0.586 1.414-0.586 1.051 0.223 1.414 0.586 0.586 0.861 0.586 1.414z"></path></symbol> 322 + 323 + <symbol id="icon-x-circle" viewBox="0 0 24 24"><path d="M23 12c0-3.037-1.232-5.789-3.222-7.778s-4.741-3.222-7.778-3.222-5.789 1.232-7.778 3.222-3.222 4.741-3.222 7.778 1.232 5.789 3.222 7.778 4.741 3.222 7.778 3.222 5.789-1.232 7.778-3.222 3.222-4.741 3.222-7.778zM21 12c0 2.486-1.006 4.734-2.636 6.364s-3.878 2.636-6.364 2.636-4.734-1.006-6.364-2.636-2.636-3.878-2.636-6.364 1.006-4.734 2.636-6.364 3.878-2.636 6.364-2.636 4.734 1.006 6.364 2.636 2.636 3.878 2.636 6.364zM8.293 9.707l2.293 2.293-2.293 2.293c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0l2.293-2.293 2.293 2.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-2.293-2.293 2.293-2.293c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-2.293 2.293-2.293-2.293c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414z"></path></symbol> 324 + 325 + <symbol id="icon-svg-search" viewBox="0 0 24 24"> 326 + <title>Search</title> 327 + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"> 328 + <circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line> 329 + </svg> 330 + </symbol> 331 + 332 + <symbol id="icon-svg-doc" viewBox="0 0 24 24"> 333 + <title>Document</title> 334 + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file"> 335 + <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline> 336 + </svg> 337 + </symbol> 338 + </defs> 339 + </svg> 340 + 341 + <script src="./js/highlight.min.js?v=GLEAM_VERSION_HERE"></script> 342 + <script src="./js/highlightjs-gleam.js?v=GLEAM_VERSION_HERE"></script> 343 + <script src="./js/highlightjs-erlang.min.js?v=GLEAM_VERSION_HERE"></script> 344 + <script src="./js/highlightjs-elixir.min.js?v=GLEAM_VERSION_HERE"></script> 345 + <script src="./js/highlightjs-javascript.min.js?v=GLEAM_VERSION_HERE"></script> 346 + <script src="./js/highlightjs-typescript.min.js?v=GLEAM_VERSION_HERE"></script> 347 + <script> 348 + document.querySelectorAll("pre code").forEach((elem) => { 349 + if (elem.className === "") { 350 + elem.classList.add("gleam"); 351 + } 352 + }); 353 + hljs.highlightAll(); 354 + </script> 355 + <script src="./js/lunr.min.js?v=GLEAM_VERSION_HERE"></script> 356 + <script src="./js/index.js?v=0"></script> 357 + 358 + <!-- Load the search index using JSONP to avoid CORS issues --> 359 + <script src="./search-data.js?v=0"></script> 360 + </body> 361 + </html>
+331
compiler-core/src/docs/snapshots/gleam_core__docs__tests__markdown_code_from_module_comment_is_trimmed.snap
··· 1 + --- 2 + source: compiler-core/src/docs/tests.rs 3 + expression: "compile(config, modules)" 4 + --- 5 + //// app.html 6 + 7 + <!DOCTYPE html> 8 + <html> 9 + <head> 10 + <meta charset="utf-8"/> 11 + <meta name="viewport" content="width=device-width, initial-scale=1"/> 12 + <title>app · · v0.1.0</title> 13 + <meta name="description" content=""/> 14 + <meta name="theme-color" content="#ffaff3" media="(prefers-color-scheme: light)"/> 15 + <meta name="theme-color" content="#33384d" media="(prefers-color-scheme: dark)"/> 16 + <link rel="stylesheet" href="./css/index.css?v=GLEAM_VERSION_HERE" type="text/css"/> 17 + <!-- The docs_config.js file is provided by HexDocs and shared 18 + between multiple versions of the same package. --> 19 + <script src="./docs_config.js"></script> 20 + <link id="syntax-theme" rel="stylesheet" href="./css/atom-one-light.min.css?v=GLEAM_VERSION_HERE"/> 21 + </head> 22 + <body class="prewrap-off theme-light drawer-closed"> 23 + <script> 24 + "use strict"; 25 + 26 + /* gleamConfig format: 27 + * // object with one or more options 28 + * {option: { 29 + * // array of values 30 + * values: [{ 31 + * // this value 32 + * value: "off", 33 + * // optional button label 34 + * label: "default", 35 + * // optional array of icons 36 + * icons: ["star", "toggle-left", ...], 37 + * }, ...], 38 + * 39 + * // value update function 40 + * update: () => {...}, 41 + * 42 + * // optional callback function 43 + * callback: (value) => {...}, 44 + * }, ...}; 45 + */ 46 + window.unnest = '.'; 47 + const gleamConfig = { 48 + theme: { 49 + values: (() => { 50 + const dark = { 51 + value: "dark", 52 + label: "Switch to light mode", 53 + icons: ["moon"], 54 + }; 55 + const light = { 56 + value: "light", 57 + label: "Switch to dark mode", 58 + icons: ["sun"], 59 + }; 60 + return ( 61 + window.matchMedia("(prefers-color-scheme: dark)").matches 62 + ? [dark, light] 63 + : [light, dark] 64 + ).map((item, index) => { 65 + item.icons.push(`toggle-${0 === index ? "left" : "right"}`); 66 + return item; 67 + }); 68 + })(), 69 + 70 + update: () => "light" === Gleam.getProperty("theme") ? "dark" : "light", 71 + 72 + callback: function(value) { 73 + const syntaxThemes = { 74 + dark: "atom-one-dark", 75 + light: "atom-one-light", 76 + }; 77 + const syntaxTheme = document.querySelector("#syntax-theme"); 78 + const hrefParts = syntaxTheme.href.match( 79 + /^(.*?)([^/\\#?]+?)((?:\.min)?\.css.*)$/i 80 + ); 81 + if (syntaxThemes[value] !== hrefParts[2]) { 82 + hrefParts[2] = syntaxThemes[value]; 83 + hrefParts.shift(); 84 + syntaxTheme.href = hrefParts.join(""); 85 + } 86 + }, 87 + }, 88 + prewrap: { 89 + values: [ 90 + { 91 + value: "off", 92 + label: "Switch to line-wrapped snippets", 93 + icons: ["more-horizontal", "toggle-left"], 94 + }, 95 + { 96 + value: "on", 97 + label: "Switch to non-wrapped snippets", 98 + icons: ["more-vertical", "toggle-right"], 99 + }, 100 + ], 101 + 102 + update: () => "off" === Gleam.getProperty("prewrap") ? "on" : "off", 103 + }, 104 + }; 105 + </script> 106 + 107 + <script> 108 + "use strict"; 109 + 110 + /* Initialise options before any content loads */ 111 + void function() { 112 + for (const property in gleamConfig) { 113 + const name = `Gleam.${property}`; 114 + 115 + let value; 116 + 117 + try { 118 + value = localStorage.getItem(name); 119 + if (value.startsWith('"') && value.endsWith('"')) { 120 + localStorage.setItem(name, value.slice(1, value.length - 1)); 121 + } 122 + } 123 + catch (_error) {} 124 + 125 + const defaultValue = gleamConfig[property].values[0].value; 126 + try { 127 + value = localStorage.getItem(name); 128 + } 129 + catch(_error) {} 130 + if (-1 < [null, undefined].indexOf(value)) { 131 + value = defaultValue; 132 + } 133 + const bodyClasses = document.body.classList; 134 + bodyClasses.remove(`${property}-${defaultValue}`); 135 + bodyClasses.add(`${property}-${value}`); 136 + try { 137 + gleamConfig[property].callback(value); 138 + } 139 + catch(_error) {} 140 + } 141 + }(); 142 + </script> 143 + 144 + <header class="page-header"> 145 + <button class="sidebar-toggle" tabindex="0"> 146 + <svg class="label label-closed icon icon-menu" alt="Open Menu" title="Open Menu"><use xlink:href="#icon-menu"></use></svg> 147 + <svg class="label label-open icon icon-x-circle" alt="Close Menu" title="Close Menu"><use xlink:href="#icon-x-circle"></use></svg> 148 + </button> 149 + 150 + <h2> 151 + <a href="./"></a> 152 + <span id="project-version"> 153 + <span> - v0.1.0 </span> 154 + </span> 155 + <script> 156 + "use strict"; 157 + 158 + if ("undefined" !== typeof versionNodes) { 159 + const currentVersion = "v0.1.0"; 160 + if (! versionNodes.find(element => element.version === currentVersion)) { 161 + versionNodes.unshift({ version: currentVersion, url: "#" }); 162 + } 163 + document.querySelector("#project-version").innerHTML = 164 + versionNodes.reduce( 165 + (acc, element) => { 166 + const status = 167 + currentVersion === element.version ? "selected disabled" : ""; 168 + return ` 169 + ${acc} 170 + <option value="${element.url}" ${status}> 171 + ${element.version} 172 + </option> 173 + `; 174 + }, 175 + ` 176 + <form autocomplete="off"> 177 + <select onchange="window.location.href = this.value"> 178 + ` 179 + ) + ` 180 + </select> 181 + <svg class="icon icon-chevrons-down"><use xlink:href="#icon-chevrons-down"></use></svg> 182 + </form> 183 + `; 184 + } 185 + </script> 186 + </h2> 187 + <div class="search"> 188 + <div class="search-input-wrap"> 189 + <input type="text" id="search-input" class="search-input" tabindex="0" aria-label="Search " autocomplete="off"> 190 + <label for="search-input" class="search-label"><svg viewBox="0 0 24 24" class="search-icon"><use xlink:href="#icon-svg-search"></use></svg></label> 191 + </div> 192 + <div id="search-results" class="search-results"></div> 193 + </div> 194 + 195 + <button class="search-nav-button" id="search-nav-button" tabindex="0"> 196 + <svg class="label icon icon-x-circle" alt="Open Search" title="Open Search"><use xlink:href="#icon-svg-search"></use></svg> 197 + </button> 198 + 199 + </header> 200 + 201 + <div class="page"> 202 + <nav class="sidebar"> 203 + <button class="sidebar-toggle" tabindex="1"> 204 + <svg class="label icon icon-x-circle" alt="Close Menu" title="Close Menu"><use xlink:href="#icon-x-circle"></use></svg> 205 + </button> 206 + 207 + 208 + 209 + 210 + <h2>Links</h2> 211 + <ul> 212 + 213 + <li><a href="https://hex.pm/packages/">Hex</a></li> 214 + 215 + </ul> 216 + 217 + 218 + <h2>Modules</h2> 219 + <ul> 220 + 221 + <li><a href="./app.html">app</a></li> 222 + 223 + </ul> 224 + 225 + 226 + 227 + 228 + 229 + 230 + 231 + 232 + </nav> 233 + 234 + <main class="content"> 235 + 236 + <h1 id="module-name" class="module-name"> 237 + <a href="#module-name">app</a> 238 + <svg class="icon icon-gleam-chasse"><use xlink:href="#icon-gleam-chasse"></use></svg> 239 + </h1> 240 + <p>Here’s an example code snippet:</p> 241 + <pre><code>wibble 242 + |&gt; wobble 243 + </code></pre> 244 + 245 + 246 + 247 + 248 + 249 + 250 + 251 + 252 + </main> 253 + <div class="search-overlay"></div> 254 + </div> 255 + 256 + <script> 257 + "use strict"; 258 + const pride = () => document.body.classList.toggle("show-pride"); 259 + </script> 260 + <a class="pride-button" onclick="pride()">✨</a> 261 + <footer class="pride" onclick="pride()"> 262 + <div class="blue">Lucy</div> 263 + <div class="pink">says</div> 264 + <div class="white">trans</div> 265 + <div class="pink">rights</div> 266 + <div class="blue">now</div> 267 + </footer> 268 + 269 + <svg class="svg-lib" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> 270 + <defs> 271 + <symbol id="icon-chevrons-down" viewBox="0 0 24 24"><path d="M6.293 13.707l5 5c0.391 0.391 1.024 0.391 1.414 0l5-5c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-4.293 4.293-4.293-4.293c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414zM6.293 6.707l5 5c0.391 0.391 1.024 0.391 1.414 0l5-5c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-4.293 4.293-4.293-4.293c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414z"></path></symbol> 272 + 273 + <symbol id="icon-gleam-chasse" viewBox="0 0 180 22"><path d="m0.00798 15.6c0.784-1.73 0.754-2.11 1.94-3.97 1.17-0.28 2.66-0.119 3.71-0.524 1.12 0.501 1.85 0.729 3.35-0.466 0.942-0.806 2.41 0.656 3.41-0.0865 2.53-1.48 0.972-1.03 5.14-0.585 1.79-0.493 3.46-0.852 6.64-1.06 3.8-0.331 0.0108-1.06 5.16-1.16 0.874-0.835 3.43-1.34 5.49-0.963 2.17-1.41 0.488-1.58 2.64-0.426 4.36-0.0592 0.83-1.08 5.39-1.22 3.27-0.264 0.843-0.471 2.82 0.187 2.13-0.254 1.36-0.525 3.67 0.709 1.77 1.66 0.962 0.181 1.9 2.32 0.26 0.593 0.304 1.71 0.814 1.74 3.67-0.833-0.0875 0.536 4.63-0.838 0.719-0.891 4.42 0.255 3.8-0.806 2.07 0.119 2.75-0.7 6.07-0.822 1.48-1.17 2.26 0.943 3.4-0.974 0.391 0.166-1.61-0.548 3.88-0.154 2.93-1.26-1.74 0.103 4.21-0.851 3.52 8e-3 0.233-0.263 3.33-0.811 1.06-1.46-0.459-1.02 5.55-0.963 2.61-2.11 0.281-1.59 4.88-0.572 0.699 0.597 3.05 1.65 3.99 3.26 0.863-0.152 2.77 0.0659 3.41-0.626 2.24-1.04-0.0635-1.05 3.37-1.34 2.1 0.115 2.2-1.21 2.77-0.679 5.91-0.778 1.96-1.63 4.89-1.49 5.47 0.212 0.204 1.22 3.99-0.265 2.14-0.0482 0.411-0.776 2.93-0.892 2.17-0.148 0.604-0.262 2.54-1.52 0.804 0.0911 1.11 0.562 1.23 1.57 0.468 1.54 0.966 3.31 1.86 4.62 2.67-0.472-0.76-0.582 4.72-0.393 3.14 0.131 3.72-0.565 6.16-0.724 4.54-0.853 1.37-0.939 5.89-0.58 10.1-1.7 2.9-0.523 10.2-1.15 4.86-0.211 4.69-0.969 7.4-1.04 3.46-0.0576 3.13 0.58 3.83 0 3.63 0.257 2.5-0.141 7.74-0.46 2.23 1.09-0.13 0.518 5.9 0.145 1.12-0.0184 2.85-6e-3 3.83-0.186 0.748 0.694 1.01 1.4 1.58 2.33-0.112 0.687-0.306 0.992-0.454 1.51 0.0805 0.459-0.0486 0.901 0.226 1.36 0.057 0.859-1.34 1.08-2.69 0.127-3.53-0.828-1.21-0.849-7.23 0.974-5.16-0.286-1.66-0.354-7.64 0.321-1.48 0.961-4.73 0.287-6.76 0.551-4.01 0.178-1.95-0.517-3.33 0.624-5.29 1.8-3.12 1.47-5.66 0.941-5.26 0.0339-2.08-0.772-4.75 0.424-6.08 2.5-3.35 1.33-7.54 2.02-6.37-0.269-3.02 1.17-6.76 0.468-0.975 0.1-2.43 0.343-3.46 0.786-1.5-0.748-1.92 0.689-3.38 0.363-0.83-0.0851-2.1-0.343-3.5-0.0239-1.28 0.81-3.87-0.666-5.67-2.17-0.131-0.478-0.106-0.902-0.403-1.69-1.63 0.392-0.668 0.395-4.29 1.14-2.71 0.289 0.131 0.495-3.22 0.964-0.638 0.331-0.998 1.17-3.15 1.04-3.09 0.469-4.48 2.1-3.66 0.577-2.95 0.347-2.9 1.82-5.86 1.85-3.3 0.815 0.192 0.978-5.2 1.66-2.81 2.66 0.0387 0.735-4.21 1.29-1.43-0.911-2.24-2.29-3.89-3.63-0.363-0.679 0.258-1.84-0.375-2.28-5.28 1.39 0.176-0.925-5.08 1.01-10.6 1.42-4.55 1.88-9.18 1.66-6.73 1.35-4.11 1.99-10.2 2.31-4.53 1.09-1.63-0.398-5.52 1.02-3.15 0.522-2.41-0.0562-4.51 1.04-0.76 0.379-0.865-0.416-2.75-0.0493-3.5-3.45-2.85-0.892-2.93-6.14-4.41 0.837 0.477 0.703-6.18 1.2-4.59 0.0171-1.93 1.02-7.41 1.04-0.815 0.505-2.55 0.453-4.13 0.791-5 0.71-5.97 2-8.46 1.61-1.39 1.09-2.58 1.53-4.22 2.62-0.919 0.756-3.45 0.596-4.48 0.492-0.525-0.406-0.751-1.2-1.82-3.28 0.149-0.902-0.325-1.44-0.248-2.8z"></path></symbol> 274 + 275 + <symbol id="icon-gleam-chasse-2" viewBox="0 0 108 22"><path d="m0.585 18.5c-0.578-1.54-0.65-1.33-0.543-2.64 0.271-1.19 0.153-1.06 1.27-1.71 0.993 0.124 1.94-0.662 2.94-0.869 2.48 0.119 0.772 0.443 2.99-0.366 1.66-1.91 0.764 0.783 3.36-0.992 2.37 0.314 4.26-1.5 5.16-1.26 0.387 0.627 0.202 0.412 2.52-0.776 4.89-1.57 3.91-1.47 5-0.972 2.05-1.09-0.0615-0.49 2.79-1.2 4.47-0.514 3.62 0.127 4.18-1.19 4.3-0.613 2.56-1.49 4.09-0.847 1.8-1.51 1.01 0.157 2.64-0.722 4.91-1.28 1.39 0.553 4.43-0.843 1.28-0.387 2.72-0.427 4.05-0.748 0.332-0.942 1.93 0.121 2.75-0.817 3 0.294-0.74-0.514 3.35-0.219 2.34-1.12 0.474 0.505 3.01-1.33 0.779-0.552 0.958 0.919 2.76-0.331 1.26-0.027 0.231 0.642 1.71 0.0417 1.08-0.234-0.332-0.25 1.4-0.727 1.07 0.281 0.347 0.858 2.47 1.86 1.02 2.09-0.0407 0.967 0.473 3.88-0.19 1.31 0.095 0.629-1.34 1.44-0.351 0.381-0.494 0.132-0.0505 0.773 5.7-0.865 2.24-0.0704 4.31-0.722 1.39-0.602 3.12 0.189 3.85-0.396 5.52-1.74 1.2 0.802 5.56-0.972 5.77-0.78 5.5-0.0267 5.87-0.622 1.29-0.593 0.466-0.184 2.73-0.0872 0.586-0.907-0.0863-0.919 1.23-0.644 0.471-1.23 3.03 0.227 3.86-0.234 1.2 0.319 2.27 0.00513 2.55 0.264 0.378 0.998 1.18 1.79 1.78 2.57-0.109 0.798 0.472 1.14 0.254 2.4 2.25-0.43 1.69-0.298 4.1-0.338 2.35-1.11 0.595 0.263 3.12-0.813 1.5-0.153 2.17 0.044 3.29-0.328 1.39-0.699 0.859-0.135 1.88-0.671 1.35 0.779 0.389 0.64 1.39 1.7 0.132 1.37 0.34 1.03 0.117 2.21-0.619 0.327-0.757 0.0587-1.28 0.739-2.68 0.688-0.161 0.395-2.5 0.734-1.97-0.203-0.915-0.0737-3.21 0.454-1.76 1.41-0.982 1.12-2.36 1.43-1.65 0.974 0.119-0.784-2.27 0.501-0.883 0.361-1.2 0.471-1.88 0.827-2.84 1.1-1.72-0.0496-3.18 1.37-2.38 0.689-1.82 0.324-2.65 1.27-3.52 0.658-2.07-0.49-3.27-0.419-1.85-2.19 0.14-0.414-1.87-2.62-0.551-2.06-0.527-0.977 0.131-2.63 0.366-1.44 0.369-0.627 1.15-1.88-1.79 0.433-1.64 0.163-5.6 0.781-3.59 1.82-0.592-0.17-4.29 0.729-0.705 0.598-0.369 0.995-1.59-0.0892-0.655 0.638-0.104 0.42-2.9 0.621-3.6 1.1-2.83 1.29-4.17 0.742 0.0193-1.05-1.8 1.24-2.18 0.454-2.51 0.61-1.36 0.795-3.64 0.594-0.211 0.804-4.14-0.139-5.09 0.879-3.61 0.381 0.127-0.296-3.51-1.03-1.44-1.87-1.14-0.196-1.22-3.01 0.14-1.2-0.505-0.638-0.0251-2.39-2.64 0.466-1.25-0.372-3.55 0.344-4.12 0.781-0.26 1.32-4.36 1.02-1.78 0.235 0.327 0.568-3.16 0.555-1.36 0.861-0.709 0.778-2.01 0.649-4.07 1.1-0.948 0.904-4.54 1.17-1.27 0.686-4.67 0.341-4.6 1.04-2.47 0.466-0.707 1.46-3.49 0.582-2.93 1.39-0.739 1.31-4.38 1.56-3.21 1.23-0.735 1.93-3.87 1.14-2.82 1.91-0.676 1.23-4.04 1.82-1.97 1.47 0.312 0.745-2.95 0.812-3.51 1.54 0.0965-0.473-4.27 1.39-2.68 0.382-1.75 0.682-3.32-0.585-1.65-1.61 0.361-0.307-1.37-2.31z"></path></symbol> 276 + 277 + <symbol id="icon-menu" viewBox="0 0 24 24"><path d="M3 13h18c0.552 0 1-0.448 1-1s-0.448-1-1-1h-18c-0.552 0-1 0.448-1 1s0.448 1 1 1zM3 7h18c0.552 0 1-0.448 1-1s-0.448-1-1-1h-18c-0.552 0-1 0.448-1 1s0.448 1 1 1zM3 19h18c0.552 0 1-0.448 1-1s-0.448-1-1-1h-18c-0.552 0-1 0.448-1 1s0.448 1 1 1z"></path></symbol> 278 + 279 + <symbol id="icon-moon" viewBox="0 0 24 24"><path d="M21.996 12.882c0.022-0.233-0.038-0.476-0.188-0.681-0.325-0.446-0.951-0.544-1.397-0.219-0.95 0.693-2.060 1.086-3.188 1.162-1.368 0.092-2.765-0.283-3.95-1.158-1.333-0.985-2.139-2.415-2.367-3.935s0.124-3.124 1.109-4.456c0.142-0.191 0.216-0.435 0.191-0.691-0.053-0.55-0.542-0.952-1.092-0.898-2.258 0.22-4.314 1.18-5.895 2.651-1.736 1.615-2.902 3.847-3.137 6.386-0.254 2.749 0.631 5.343 2.266 7.311s4.022 3.313 6.772 3.567 5.343-0.631 7.311-2.266 3.313-4.022 3.567-6.772zM19.567 14.674c-0.49 1.363-1.335 2.543-2.416 3.441-1.576 1.309-3.648 2.016-5.848 1.813s-4.108-1.278-5.417-2.854-2.016-3.648-1.813-5.848c0.187-2.032 1.117-3.814 2.507-5.106 0.782-0.728 1.71-1.3 2.731-1.672-0.456 1.264-0.577 2.606-0.384 3.899 0.303 2.023 1.38 3.934 3.156 5.247 1.578 1.167 3.448 1.668 5.272 1.545 0.752-0.050 1.496-0.207 2.21-0.465z"></path></symbol> 280 + 281 + <symbol id="icon-more-horizontal" viewBox="0 0 24 24"><path d="M14 12c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414zM21 12c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414zM7 12c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414z"></path></symbol> 282 + 283 + <symbol id="icon-more-vertical" viewBox="0 0 24 24"><path d="M14 12c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414zM14 5c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414zM14 19c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414z"></path></symbol> 284 + 285 + <symbol id="icon-star" viewBox="0 0 24 24"><path d="M12.897 1.557c-0.092-0.189-0.248-0.352-0.454-0.454-0.495-0.244-1.095-0.041-1.339 0.454l-2.858 5.789-6.391 0.935c-0.208 0.029-0.411 0.127-0.571 0.291-0.386 0.396-0.377 1.029 0.018 1.414l4.623 4.503-1.091 6.362c-0.036 0.207-0.006 0.431 0.101 0.634 0.257 0.489 0.862 0.677 1.351 0.42l5.714-3.005 5.715 3.005c0.186 0.099 0.408 0.139 0.634 0.101 0.544-0.093 0.91-0.61 0.817-1.155l-1.091-6.362 4.623-4.503c0.151-0.146 0.259-0.344 0.292-0.572 0.080-0.546-0.298-1.054-0.845-1.134l-6.39-0.934zM12 4.259l2.193 4.444c0.151 0.305 0.436 0.499 0.752 0.547l4.906 0.717-3.549 3.457c-0.244 0.238-0.341 0.569-0.288 0.885l0.837 4.883-4.386-2.307c-0.301-0.158-0.647-0.148-0.931 0l-4.386 2.307 0.837-4.883c0.058-0.336-0.059-0.661-0.288-0.885l-3.549-3.457 4.907-0.718c0.336-0.049 0.609-0.26 0.752-0.546z"></path></symbol> 286 + 287 + <symbol id="icon-sun" viewBox="0 0 24 24"><path d="M18 12c0-1.657-0.673-3.158-1.757-4.243s-2.586-1.757-4.243-1.757-3.158 0.673-4.243 1.757-1.757 2.586-1.757 4.243 0.673 3.158 1.757 4.243 2.586 1.757 4.243 1.757 3.158-0.673 4.243-1.757 1.757-2.586 1.757-4.243zM16 12c0 1.105-0.447 2.103-1.172 2.828s-1.723 1.172-2.828 1.172-2.103-0.447-2.828-1.172-1.172-1.723-1.172-2.828 0.447-2.103 1.172-2.828 1.723-1.172 2.828-1.172 2.103 0.447 2.828 1.172 1.172 1.723 1.172 2.828zM11 1v2c0 0.552 0.448 1 1 1s1-0.448 1-1v-2c0-0.552-0.448-1-1-1s-1 0.448-1 1zM11 21v2c0 0.552 0.448 1 1 1s1-0.448 1-1v-2c0-0.552-0.448-1-1-1s-1 0.448-1 1zM3.513 4.927l1.42 1.42c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-1.42-1.42c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414zM17.653 19.067l1.42 1.42c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-1.42-1.42c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414zM1 13h2c0.552 0 1-0.448 1-1s-0.448-1-1-1h-2c-0.552 0-1 0.448-1 1s0.448 1 1 1zM21 13h2c0.552 0 1-0.448 1-1s-0.448-1-1-1h-2c-0.552 0-1 0.448-1 1s0.448 1 1 1zM4.927 20.487l1.42-1.42c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-1.42 1.42c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0zM19.067 6.347l1.42-1.42c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-1.42 1.42c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0z"></path></symbol> 288 + 289 + <symbol id="icon-toggle-left" viewBox="0 0 24 24"><path d="M8 4c-2.209 0-4.21 0.897-5.657 2.343s-2.343 3.448-2.343 5.657 0.897 4.21 2.343 5.657 3.448 2.343 5.657 2.343h8c2.209 0 4.21-0.897 5.657-2.343s2.343-3.448 2.343-5.657-0.897-4.21-2.343-5.657-3.448-2.343-5.657-2.343zM8 6h8c1.657 0 3.156 0.67 4.243 1.757s1.757 2.586 1.757 4.243-0.67 3.156-1.757 4.243-2.586 1.757-4.243 1.757h-8c-1.657 0-3.156-0.67-4.243-1.757s-1.757-2.586-1.757-4.243 0.67-3.156 1.757-4.243 2.586-1.757 4.243-1.757zM12 12c0-1.104-0.449-2.106-1.172-2.828s-1.724-1.172-2.828-1.172-2.106 0.449-2.828 1.172-1.172 1.724-1.172 2.828 0.449 2.106 1.172 2.828 1.724 1.172 2.828 1.172 2.106-0.449 2.828-1.172 1.172-1.724 1.172-2.828zM10 12c0 0.553-0.223 1.051-0.586 1.414s-0.861 0.586-1.414 0.586-1.051-0.223-1.414-0.586-0.586-0.861-0.586-1.414 0.223-1.051 0.586-1.414 0.861-0.586 1.414-0.586 1.051 0.223 1.414 0.586 0.586 0.861 0.586 1.414z"></path></symbol> 290 + 291 + <symbol id="icon-toggle-right" viewBox="0 0 24 24"><path d="M8 4c-2.209 0-4.21 0.897-5.657 2.343s-2.343 3.448-2.343 5.657 0.897 4.21 2.343 5.657 3.448 2.343 5.657 2.343h8c2.209 0 4.21-0.897 5.657-2.343s2.343-3.448 2.343-5.657-0.897-4.21-2.343-5.657-3.448-2.343-5.657-2.343zM8 6h8c1.657 0 3.156 0.67 4.243 1.757s1.757 2.586 1.757 4.243-0.67 3.156-1.757 4.243-2.586 1.757-4.243 1.757h-8c-1.657 0-3.156-0.67-4.243-1.757s-1.757-2.586-1.757-4.243 0.67-3.156 1.757-4.243 2.586-1.757 4.243-1.757zM20 12c0-1.104-0.449-2.106-1.172-2.828s-1.724-1.172-2.828-1.172-2.106 0.449-2.828 1.172-1.172 1.724-1.172 2.828 0.449 2.106 1.172 2.828 1.724 1.172 2.828 1.172 2.106-0.449 2.828-1.172 1.172-1.724 1.172-2.828zM18 12c0 0.553-0.223 1.051-0.586 1.414s-0.861 0.586-1.414 0.586-1.051-0.223-1.414-0.586-0.586-0.861-0.586-1.414 0.223-1.051 0.586-1.414 0.861-0.586 1.414-0.586 1.051 0.223 1.414 0.586 0.586 0.861 0.586 1.414z"></path></symbol> 292 + 293 + <symbol id="icon-x-circle" viewBox="0 0 24 24"><path d="M23 12c0-3.037-1.232-5.789-3.222-7.778s-4.741-3.222-7.778-3.222-5.789 1.232-7.778 3.222-3.222 4.741-3.222 7.778 1.232 5.789 3.222 7.778 4.741 3.222 7.778 3.222 5.789-1.232 7.778-3.222 3.222-4.741 3.222-7.778zM21 12c0 2.486-1.006 4.734-2.636 6.364s-3.878 2.636-6.364 2.636-4.734-1.006-6.364-2.636-2.636-3.878-2.636-6.364 1.006-4.734 2.636-6.364 3.878-2.636 6.364-2.636 4.734 1.006 6.364 2.636 2.636 3.878 2.636 6.364zM8.293 9.707l2.293 2.293-2.293 2.293c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0l2.293-2.293 2.293 2.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-2.293-2.293 2.293-2.293c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-2.293 2.293-2.293-2.293c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414z"></path></symbol> 294 + 295 + <symbol id="icon-svg-search" viewBox="0 0 24 24"> 296 + <title>Search</title> 297 + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"> 298 + <circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line> 299 + </svg> 300 + </symbol> 301 + 302 + <symbol id="icon-svg-doc" viewBox="0 0 24 24"> 303 + <title>Document</title> 304 + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file"> 305 + <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline> 306 + </svg> 307 + </symbol> 308 + </defs> 309 + </svg> 310 + 311 + <script src="./js/highlight.min.js?v=GLEAM_VERSION_HERE"></script> 312 + <script src="./js/highlightjs-gleam.js?v=GLEAM_VERSION_HERE"></script> 313 + <script src="./js/highlightjs-erlang.min.js?v=GLEAM_VERSION_HERE"></script> 314 + <script src="./js/highlightjs-elixir.min.js?v=GLEAM_VERSION_HERE"></script> 315 + <script src="./js/highlightjs-javascript.min.js?v=GLEAM_VERSION_HERE"></script> 316 + <script src="./js/highlightjs-typescript.min.js?v=GLEAM_VERSION_HERE"></script> 317 + <script> 318 + document.querySelectorAll("pre code").forEach((elem) => { 319 + if (elem.className === "") { 320 + elem.classList.add("gleam"); 321 + } 322 + }); 323 + hljs.highlightAll(); 324 + </script> 325 + <script src="./js/lunr.min.js?v=GLEAM_VERSION_HERE"></script> 326 + <script src="./js/index.js?v=0"></script> 327 + 328 + <!-- Load the search index using JSONP to avoid CORS issues --> 329 + <script src="./search-data.js?v=0"></script> 330 + </body> 331 + </html>
+16 -4
compiler-core/src/docs/snapshots/gleam_core__docs__tests__markdown_code_from_standalone_pages_is_not_trimmed.snap
··· 1 1 --- 2 2 source: compiler-core/src/docs/tests.rs 3 - expression: "compile_with_docs_pages(config, vec![], pages)" 3 + expression: "compile_with_markdown_pages(config, vec![], pages)" 4 4 --- 5 - //// one.md.html 5 + //// one.html 6 6 7 7 <!DOCTYPE html> 8 8 <html> 9 9 <head> 10 10 <meta charset="utf-8"/> 11 11 <meta name="viewport" content="width=device-width, initial-scale=1"/> 12 - <title>one.md · · v0.1.0</title> 12 + <title>one · · v0.1.0</title> 13 13 <meta name="description" content=""/> 14 14 <meta name="theme-color" content="#ffaff3" media="(prefers-color-scheme: light)"/> 15 15 <meta name="theme-color" content="#33384d" media="(prefers-color-scheme: dark)"/> ··· 208 208 <h2>Pages</h2> 209 209 <ul> 210 210 211 - <li><a href="./one.md.html">one.md</a></li> 211 + <li><a href="./one.html">one</a></li> 212 212 213 213 </ul> 214 214 215 215 216 216 217 + <h2>Links</h2> 218 + <ul> 219 + 220 + <li><a href="https://hex.pm/packages/">Hex</a></li> 221 + 222 + </ul> 223 + 217 224 218 225 <h2>Modules</h2> 219 226 <ul> ··· 225 232 226 233 <main class="content"> 227 234 235 + <p>This is an example code snippet that should be indented</p> 236 + <pre><code class="language-gleam">pub fn indentation_test() { 237 + todo as "This line should be indented by two spaces" 238 + } 239 + </code></pre> 228 240 229 241 230 242 </main>
+66 -13
compiler-core/src/docs/tests.rs
··· 13 13 use ecow::EcoString; 14 14 use itertools::Itertools; 15 15 16 - fn compile_with_docs_pages( 16 + fn compile_with_markdown_pages( 17 17 config: PackageConfig, 18 18 modules: Vec<(&str, &str)>, 19 - docs_pages: Vec<(&str, &str)>, 19 + markdown_pages: Vec<(&str, &str)>, 20 20 ) -> EcoString { 21 21 let fs = InMemoryFileSystem::new(); 22 22 for (name, src) in modules { 23 - fs.write(&Utf8PathBuf::from(format!("/src/{}", name)), src) 23 + fs.write(&Utf8PathBuf::from(format!("/src/{name}")), src) 24 + .unwrap(); 25 + } 26 + 27 + // We're saving the pages under a different `InMemoryFileSystem` for these 28 + // tests so we don't have to juggle with borrows and lifetimes. 29 + // The package compiler is going to take ownership of `fs` but later 30 + // `generate_html` also needs a `FileSystemReader` to go and read the 31 + // markdown pages' content. 32 + let pages_fs = InMemoryFileSystem::new(); 33 + for (title, src) in markdown_pages.iter() { 34 + pages_fs 35 + .write(&Utf8PathBuf::from(format!("{title}.md")), src) 24 36 .unwrap(); 25 37 } 26 38 ··· 53 65 module.attach_doc_and_module_comments(); 54 66 } 55 67 56 - let docs_pages = docs_pages 68 + let docs_pages = markdown_pages 57 69 .into_iter() 58 - .map(|(title, source)| DocsPage { 70 + .map(|(title, _)| DocsPage { 59 71 title: (*title).into(), 60 - path: format!("{}.html", title).into(), 61 - source: (*source).into(), 72 + path: format!("{title}.html"), 73 + source: format!("{title}.md").into(), 62 74 }) 63 75 .collect_vec(); 64 76 ··· 67 79 &config, 68 80 &modules, 69 81 &docs_pages, 82 + pages_fs, 70 83 SystemTime::UNIX_EPOCH, 71 84 ) 72 85 .into_iter() ··· 87 100 } 88 101 89 102 pub fn compile(config: PackageConfig, modules: Vec<(&str, &str)>) -> EcoString { 90 - compile_with_docs_pages(config, modules, vec![]) 103 + compile_with_markdown_pages(config, modules, vec![]) 91 104 } 92 105 93 106 #[test] ··· 206 219 fn markdown_code_from_standalone_pages_is_not_trimmed() { 207 220 let config = PackageConfig::default(); 208 221 let pages = vec![( 209 - "one.md", 210 - "```gleam 211 - testing 212 - indentation 222 + "one", 223 + " 224 + This is an example code snippet that should be indented 225 + ```gleam 226 + pub fn indentation_test() { 227 + todo as \"This line should be indented by two spaces\" 228 + } 213 229 ```", 214 230 )]; 215 - insta::assert_snapshot!(compile_with_docs_pages(config, vec![], pages)); 231 + insta::assert_snapshot!(compile_with_markdown_pages(config, vec![], pages)); 232 + } 233 + 234 + #[test] 235 + fn markdown_code_from_function_comment_is_trimmed() { 236 + let config = PackageConfig::default(); 237 + let modules = vec![( 238 + "app.gleam", 239 + " 240 + /// Here's an example code snippet: 241 + /// ``` 242 + /// wibble 243 + /// |> wobble 244 + /// ``` 245 + /// 246 + pub fn indentation_test() { 247 + todo 248 + } 249 + ", 250 + )]; 251 + insta::assert_snapshot!(compile(config, modules)); 252 + } 253 + 254 + #[test] 255 + fn markdown_code_from_module_comment_is_trimmed() { 256 + let config = PackageConfig::default(); 257 + let modules = vec![( 258 + "app.gleam", 259 + " 260 + //// Here's an example code snippet: 261 + //// ``` 262 + //// wibble 263 + //// |> wobble 264 + //// ``` 265 + //// 266 + ", 267 + )]; 268 + insta::assert_snapshot!(compile(config, modules)); 216 269 }