-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into destructuring-docs
- Loading branch information
Showing
135 changed files
with
25,663 additions
and
8,966 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.vscode | ||
.idea | ||
.DS_Store | ||
*.swp | ||
node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
project_id: "723773" | ||
api_token_env: CROWDIN_PERSONAL_TOKEN | ||
preserve_hierarchy: 1 | ||
files: | ||
- source: /docs/src/content/docs/**/* | ||
translation: /docs/src/content/docs/%two_letters_code%/**/%original_file_name% | ||
ignore: | ||
- /docs/src/content/docs/%two_letters_code% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* @import {Root} from 'mdast' | ||
* @import {VFile} from 'vfile' | ||
*/ | ||
import { visit } from 'unist-util-visit'; | ||
|
||
/** | ||
* Maximum allowed characters in a Chrome | ||
* Firefox has more limit but we are using less for compatibility | ||
*/ | ||
const maxAllowedCharacters = 32779; | ||
|
||
/** | ||
* Adds links to every code block, allowing to open its contents in the Web IDE | ||
* | ||
* @returns Transform. | ||
*/ | ||
export default function remarkLinksToWebIDE() { | ||
/** | ||
* @param tree {Root} | ||
* @param file {VFile} | ||
* @return {undefined} | ||
*/ | ||
return function(tree, file) { | ||
// Specifying 'code' items guarantees non-inline code blocks | ||
visit(tree, 'code', function(node, index, parent) { | ||
// Only allow Tact code blocks | ||
if (node.lang !== 'tact') { return undefined; } | ||
|
||
// Only allow certain amount of characters | ||
let src = node.value.trim(); | ||
if (src.length > maxAllowedCharacters) { return undefined; } | ||
|
||
// Disallow single-line code blocks as they pose very little value and they're often represent function signatures in the Reference section | ||
const lines = src.split('\n'); | ||
if (lines.length <= 1) { return undefined; } | ||
|
||
// Only allow pages in the Cookbook | ||
// NOTE: This limitation can be lifted in the future if there's popular demand | ||
if (file.path.indexOf('docs/cookbook') === -1) { return undefined; } | ||
|
||
// Detect module-level items | ||
let hasModuleItems = false; | ||
for (let i = 0; i < lines.length; i += 1) { | ||
// Same regex as in scripts/check-cookbook-examples.js | ||
const matchRes = lines[i].match(/^\s*(?:import|primitive|const|asm|fun|extends|mutates|virtual|override|inline|abstract|@name|@interface|contract|trait|struct|message)\b/); | ||
// TODO: Unite the regexes when Tact 2.0 arrives (or if some new module-level item arrives, or via try/catch and re-using compiler's parser) | ||
|
||
if (matchRes !== null) { | ||
hasModuleItems = true; | ||
break; | ||
} | ||
} | ||
|
||
// Adjust the source code if the module-level items are NOT present | ||
if (!hasModuleItems) { | ||
src = [ | ||
'fun fromTactDocs() {', | ||
lines.map(line => ` ${line}`).join('\n'), | ||
'}', | ||
].join('\n'); | ||
} | ||
|
||
// Encode to URL-friendly Base64 | ||
const encoded = Buffer.from(src).toString('base64url'); | ||
|
||
// Double-check the number of characters in the link | ||
const link = `https://ide.ton.org?lang=tact&code=${encoded}`; | ||
if (link.length > maxAllowedCharacters) { return undefined; } | ||
|
||
/** @type import('mdast').Html */ | ||
const button = { | ||
type: 'html', | ||
value: [ | ||
// Constructing opening <a> tag | ||
[ | ||
// Open the tag | ||
'<a', | ||
// Make links opened in new tab | ||
'target="_blank"', | ||
// Set styles | ||
'class="web-ide-link"', | ||
// Add hyperref with > to close the tag | ||
`href="${link}">`, | ||
].join(' '), | ||
// The text to click on | ||
'<span class="web-ide-link-span">▶️ Open in Web IDE</span>', | ||
// Closing </a> tag | ||
'</a>', | ||
].join(''), | ||
}; | ||
|
||
// Place the button after the code block | ||
parent.children.splice(index + 1, 0, button); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,24 +10,26 @@ | |
"build": "yarn clean && yarn lint:all && astro check && astro build", | ||
"preview": "astro preview", | ||
"astro": "astro", | ||
"spell": "cspell --no-progress src/content/docs", | ||
"spell": "yarn cspell --no-progress src/content/docs", | ||
"lint:all": "yarn spell" | ||
}, | ||
"dependencies": { | ||
"@astrojs/check": "^0.9.3", | ||
"@astrojs/markdown-remark": "^5.2.0", | ||
"@astrojs/starlight": "^0.28.2", | ||
"astro": "^4.16.1", | ||
"@astrojs/check": "0.9.4", | ||
"@astrojs/markdown-remark": "5.3.0", | ||
"@astrojs/starlight": "0.28.4", | ||
"astro": "4.16.7", | ||
"cspell": "^8.14.4", | ||
"hast-util-to-string": "^3.0.0", | ||
"rehype-autolink-headings": "7.1.0", | ||
"rehype-katex": "7.0.1", | ||
"remark": "^15.0.1", | ||
"remark-custom-heading-id": "2.0.0", | ||
"remark-math": "6.0.0", | ||
"sharp": "^0.32.5", | ||
"starlight-links-validator": "^0.12.1", | ||
"typescript": "^5.6.2", | ||
"unist-util-visit": "^5.0.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"version": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.