From 06b1b9f137e15e0d78de6b372971a3926403650c Mon Sep 17 00:00:00 2001 From: PocketZ <45301505+pocketdr@users.noreply.github.com> Date: Thu, 12 Aug 2021 12:18:20 +0800 Subject: Update MDN/Structures/Macros and MDN/Yari of l10n-zh (#2024) * Create MDN/Tools/KumaScript * Create MDN/Tools/KumaScript/Troubleshooting * Create MDN/Tools/KumaScript * Create MDN/Tools/KumaScript/Troubleshooting * Update MDN/Structures/Macros * Update MDN/Yari * Update content of Macros and KumaScript * delete no translated articel --- files/zh-cn/mdn/structures/macros/index.html | 34 ++++---- files/zh-cn/mdn/structures/macros/other/index.html | 92 ++++++++++++++++++++++ files/zh-cn/mdn/yari/index.html | 1 - files/zh-tw/mdn/yari/index.html | 24 +++--- 4 files changed, 118 insertions(+), 33 deletions(-) create mode 100644 files/zh-cn/mdn/structures/macros/other/index.html diff --git a/files/zh-cn/mdn/structures/macros/index.html b/files/zh-cn/mdn/structures/macros/index.html index b41123ab3f..4227374bac 100644 --- a/files/zh-cn/mdn/structures/macros/index.html +++ b/files/zh-cn/mdn/structures/macros/index.html @@ -1,5 +1,5 @@ --- -title: Macros +title: 使用宏 slug: MDN/Structures/Macros tags: - Guide @@ -11,36 +11,32 @@ translation_of: MDN/Structures/Macros ---
Kuma 平台为 MDN 提供了强大的宏系统——KumaScript,使得 MDN 能够自动地去做各种东西。本文提供一些信息以便大家知道如何使用 MDN 上的文章内的宏。
+为了自动化执行某些工作,Yari 平台提供了一个强大的宏系统——KumaScript。本文提供了一些相关信息,方便你在参与编辑 MDN 时,使用这些宏。
-鉴于本文只是 KumaScript 的简介,KumaScript 指南提供了更深入的内容。
+本文只是简要介绍了 KumaScript,KumaScript 指南提供了更深入的内容,帮助你使用和掌握它。
-MDN使用的Macros(宏)是基于Node.js执行环境,并在服务端执行运行。这里包括了大量的代码库,另外对此还提供了丰富的wiki说明文档内容。如果你希望能学习到更多的内容,可以查看 KumaScript 指南, KumaScript reference 则提供了更多关于这些代码库和KumaScript的API的实现机理。
+MDN 使用宏是基于运行于服务器上的 JavaScript 代码实现的,并由 Node.js 解释执行。在此之上,已经实现了一个丰富的工具库,让宏可以与这个平台及其中的内容进行互动。
-要实际使用宏,只需将对宏的调用括在一对双括号中,其参数(如果有)括在括号中;如下:
+要实际使用宏,只需将对宏的调用和可能需要的参数写在一对双括号中,如下:
\{{macroname(parameter-list)}}
关于宏调用的一些注意事项:
\{{macroname()}}
和 \{{macroname}}
完全相同。\{{macroname()}}
和 \{{macroname}}
的效果是。宏被高度缓存;对于任何一组输入值(参数和环境值,例如运行宏的URL),结果都会被存储和重用。这意味着宏仅在输入发生变化时才实际运行。
+宏的几乎所有执行结果都会被缓存,以便被重用来加快执行速度。这意味着宏仅在输入发生变化时才实际运行,包括调用时的参数以及环境值(例如这个宏被调用时所在的路径)。
-注意: 您可以通过在浏览器中强制刷新页面(即转移重新加载)来强制重新评估页面上的所有宏。
-宏既可以用来做一些简单的工作,比如插入更大的文本块或从MDN的另一部分交换内容一样简单,也可以通过搜索站点的各个部分,设置输出样式和添加链接来构建整个内容索引。
-宏可以像插入更大的文本块或从MDN的另一部分交换内容一样简单,也可以通过搜索站点的各个部分,设置输出样式和添加链接来构建整个内容索引。
- -您可以在Commonly-used macros页面上阅读我们最常用的宏;另外,这里有complete list of all macros。大多数宏都有内置的文档,作为顶部的注释。
+您可以在常用的宏页面看到一些我们最常用到的宏,还可以在我们 Github 的仓库中,浏览所有可用的宏。大多数宏顶部的注释中,都有内置的文档帮助你了解它的作用。
diff --git a/files/zh-cn/mdn/structures/macros/other/index.html b/files/zh-cn/mdn/structures/macros/other/index.html new file mode 100644 index 0000000000..d9dd6f2ea3 --- /dev/null +++ b/files/zh-cn/mdn/structures/macros/other/index.html @@ -0,0 +1,92 @@ +--- +title: 其他需要注意的宏 +slug: MDN/Structures/Macros/Other +tags: + - Macros + - Reference +--- +In contrast to the macros listed in Commonly-used macros, the macros documented in this article are used infrequently or only in specific contexts, or are deprecated.
+ +These macros are used only with particular contexts, such as a specific API reference.
+ +Interwiki
makes it easy to create interwiki links. Currently it supports linking to Wikipedia and Wikimo. The first parameter is the name of the wiki ("wikipedia" or "wikimo"), and the second is the path of the article. For example, \{\{interwiki("wikipedia", "Firefox")\}\}
shows up as {{ interwiki("wikipedia", "Firefox") }}. This template auto-detects the page language and directs to the same language on Wikipedia, for example.RFC
creates a link to the specified RFC, given its number. The syntax is: \{\{RFC(number)\}\}
. For example, \{\{RFC(2616)\}\}
becomes {{ RFC(2616) }}.anch
macro inserts a link to an anchor. \{\{Anch("top")\}\}
produces <a href="#top">top</a>
({{ Anch("top") }}). You can also add a second parameter which contains replacement text to display as the link text.We have an assortment of macros that can be used to automatically generate the contents of landing pages. Here they are.
+ +ListSubpages
generates an unordered list of links to all the immediate children of the current page; useful for automatically generating tables of contents for sets of documentation.LandingPageListSubpages
outputs a two-column definition list of all immediate subpages of the current page, with their titles as the {{HTMLElement("dt")}} and their SEO summary as the {{HTMLElement("dd")}}. This makes it easy to automatically generate reasonably attractive landing pages.NavListWithPrioritizedPages
generates an ordered list formatted properly for use in a zone navigation sidebar (or quicklinks). As input, you can specify zero or more page slugs that should be pulled out of the main list and instead inserted at the top of the list, in the given order. All remaining pages are placed in the list alphabetically. One level of subpages is included.APIListAlpha
builds a list of the current page's subpages, formatted as a list of API terms, divided up by first letter. There are three parameters. The first is 0 if you want to include all top-level subpages or 1 to leave out subpages with "." in their names. The second and third let you add text to display as part of the name in each link. This can be used to add "<" and ">" for element links, or to add "()" at the end of lists of method names.SubpagesWithSummaries
constructs a definition list of all the immediate children of the current page. There is no other formatting done. You can get a two-column list ready for use as a multi-column landing page using LandingPageListSubpages
.We have some macros specifically designed to create quicklinks:
+ +MakeSimpleQuicklinks
macro creates a flat list of links in the quicklinks box. Give it a set of paths to destination pages as its input arguments. Each link's text is the page title, and each link has a tooltip derived from the page summary.QuickLinksWithSubpages
creates a set of quicklinks comprised of the pages below the current page (or specified page, if one is given). Up to two total levels of depth are generated.Transclusion is the embedding of part or all of one page into another. Exercise caution when using this macro, to ensure that the transcluded content makes sense in the context of the page it is embedded into.
+ +page
lets you embed some or all of a specific page into a document. It accepts five parameters:
\{{Page("/en-US/docs/MDN/About", "How you can help")}}
+ +Result:
+ +{{Page("/en-US/docs/MDN/About", "How you can help")}}
+ +\{{Page("/en-US/docs/MDN/About", "How you can help", 0, 1)}}
+ +Result:
+ +{{Page("/en-US/docs/MDN/About", "How you can help", 0, 1)}}
+ +These macros have been replace by other ways of doing the same thing, and should no longer be used. If you find them in existing articles, please replace them.
+ +SectionOnPage
macro creates a phrase that links to both the name of a section and the article containing that section. For example, \{{SectionOnPage("/en-US/docs/Mozilla/Firefox/Releases/21", "Changes for Web developers")}}
outputs the following: {{SectionOnPage("/en-US/docs/Mozilla/Firefox/Releases/21", "Changes for Web developers")}}.manch
inserts a link to a method within the current interface; this is intended only for use in interface documentation pages. \{\{manch("foo")\}\}
produces <code><a href="current/path#foo">foo()</a></code>
({{ manch("foo") }}).Link
macro inserts a link to the specified page on MDN, using the page's title as the visible string to click on, and the tooltip picked up from the page's SEO summary.LinkItem
macro inserts a link to a specified URL, with the indicated text as the visible string to click on. The link automatically picks up as its tooltip the summary of the target page. This differs from Link
in that you must specify the title.LinkItemDL
macro inserts a link to a specified URL, with the indicated text as a {{HTMLElement("dt")}} which is also the link. The {{HTMLElement("dd")}} element contains the specified page's summary.funcref
creates links to global functions (usually C++) documented on top-level pages. However, such pages are no longer created at the top-level of MDN.source
allows you to link to a Mozilla source code file without having to type a long MXR URL using this syntax: \{\{Source("browser/Makefile.in")\}\}
. This gives you: {{ Source("browser/Makefile.in") }}. The text of the link is the path provided; if you want different text, then just provide a second parameter, like so: \{\{Source("browser/Makefile.in", "the browser/ Makefile.in")\}\}
, which produces {{ Source("browser/Makefile.in", "the browser/ Makefile.in") }}. Note that the link will be to the very latest version of the file in bleeding-edge code.Source_cvs
works just like source
, except it links to the CVS repository instead of the newer mozilla-central one.LXRSearch
can be used to create an LXR search URL.Yari is the code that renders MDN Web Docs. It takes a JAMStack approach, which involves taking the MDN content stored as flat source files in a GitHub repo (which include front matter and macro calls), rendering them out to static HTML files, and serving those as quickly and efficiently as possible.
-Kuma 是由 MDN Web Docs 維護的 Django 程式碼。
+The core MDN platform now actually consists of two GitHub repos:
-{{SubpagesWithSummaries}}
- -要參與 Kuma:
+