Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Oct 29, 2024
2 parents b6113c4 + 4fd6331 commit 69154b5
Show file tree
Hide file tree
Showing 23 changed files with 477 additions and 697 deletions.
11 changes: 10 additions & 1 deletion build/flaws/broken-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import * as cheerio from "cheerio";
import { Doc } from "../../libs/types/document.js";
import { Flaw } from "./index.js";
import { ONLY_AVAILABLE_IN_ENGLISH } from "../../libs/l10n/l10n.js";
import web from "../../kumascript/src/api/web.js";
import mdn from "../../kumascript/src/api/mdn.js";

const _safeToHttpsDomains = new Map();

Expand Down Expand Up @@ -62,7 +64,14 @@ function mutateLink(
$element.attr("href", suggestion);
} else {
$element.addClass("page-not-created");
$element.attr("title", "This is a link to an unwritten page");
const locale = $element.attr("href")?.match(/^\/([^/]+)\//)?.[1] || "en-US";
const titleWhenMissing = (mdn as any).getLocalString.call(
{ env: { locale } },
web.getJSONData("L10n-Common"),
"summary"
);
$element.attr("title", titleWhenMissing);
$element.attr("href", null);
}
}

Expand Down
5 changes: 1 addition & 4 deletions build/git-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ export function gather(contentRoots, previousFile = null) {
// the git root. For example "../README.md" and since those aren't documents
// exclude them.
// We also only care about documents.
if (
!key.startsWith(".") &&
(key.endsWith("index.html") || key.endsWith("index.md"))
) {
if (!key.startsWith(".") && key.endsWith("index.md")) {
map.set(key, Object.assign(value, { merged: parents.get(value.hash) }));
}
}
Expand Down
4 changes: 4 additions & 0 deletions build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ export function postProcessExternalLinks($) {
// But we haven't applied all fixable flaws yet and we still have to
// support translated content which is quite a long time away from
// being entirely treated with the fixable flaws cleanup.
$a.attr(
"href",
$a.attr("href").replace("https://developer.mozilla.org", "") || "/"
);
return;
}
$a.addClass("external");
Expand Down
2 changes: 1 addition & 1 deletion client/pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dev": "webpack-cli --watch"
},
"dependencies": {
"@zip.js/zip.js": "2.7.52",
"@zip.js/zip.js": "2.7.53",
"dexie": "4.0.9"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions client/pwa/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@
resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==

"@zip.js/[email protected].52":
version "2.7.52"
resolved "https://registry.yarnpkg.com/@zip.js/zip.js/-/zip.js-2.7.52.tgz#bc11de93b41f09e03155bc178e7f9c2e2612671d"
integrity sha512-+5g7FQswvrCHwYKNMd/KFxZSObctLSsQOgqBSi0LzwHo3li9Eh1w5cF5ndjQw9Zbr3ajVnd2+XyiX85gAetx1Q==
"@zip.js/[email protected].53":
version "2.7.53"
resolved "https://registry.yarnpkg.com/@zip.js/zip.js/-/zip.js-2.7.53.tgz#bf88e90d8eed562182c01339643bc405446b0578"
integrity sha512-G6Bl5wN9EXXVaTUIox71vIX5Z454zEBe+akKpV4m1tUboIctT5h7ID3QXCJd/Lfy2rSvmkTmZIucf1jGRR4f5A==

acorn-import-attributes@^1.9.5:
version "1.9.5"
Expand Down
150 changes: 75 additions & 75 deletions deployer/poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions deployer/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
click = "^8.1.7"
boto3 = "^1.35.44"
boto3 = "^1.35.49"
python-decouple = "^3.8"
requests = {extras = ["security"], version = "^2.32.3"}
elasticsearch-dsl = "^7.4.1"
selectolax = "^0.3.24"
selectolax = "^0.3.25"
PyGithub = "^1.59"
unidiff = "^0.7.5"

Expand Down
2 changes: 2 additions & 0 deletions kumascript/macros/GlossarySidebar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ async function getPageLinkAndTitle(slug) {
<section id="Quick_links" data-macro="GlossarySidebar">
<ol>
<%- await renderRootItem("/docs/Glossary") %>
<li class="toggle">
<%- await template("ListSubpagesForSidebar", ['/docs/Glossary', 1]) %>
</li>
</ol>
</section>
2 changes: 1 addition & 1 deletion kumascript/macros/InheritanceDiagram.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function rectWithText(x, y, fill, interfaceName, reverse) {
const rectWidth = calculateRectWidth(interfaceName);
if (reverse) x -= rectWidth;
return `
<a style="text-decoration: none;" xlink:href="${href+interfaceName}">
<a style="text-decoration: none;" href="${href+interfaceName}">
<rect x="${x}" y="${y}" width="${rectWidth}" height="25" fill="${fill}" stroke="#D4DDE4" stroke-width="2px" />
<text x="${x+rectWidth/2}" y="${y+16}" font-size="10px" fill="#4D4E53" text-anchor="middle">
${interfaceName}
Expand Down
2 changes: 1 addition & 1 deletion kumascript/macros/MathMLElement.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ var sectionname = mdn.localString({
});
var dest = '/' + env.locale + '/docs/Web/MathML/' + sectionname + '/' + name;
var result = '<code><a href="' + dest +'" title="<' + name + '>">&lt;' + name + '&gt;</a></code>';
var result = '<a href="' + dest +'" title="<' + name + '>"><code>&lt;' + name + '&gt;</code></a>';
%>
<%- result %>
41 changes: 3 additions & 38 deletions kumascript/macros/PreviousNext.ejs
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
<%
/*
Parameter
$0 (first parameter): path of Previous page
$1 (second parameter): path of Next page
Issue
* Problem of Apostrophe (https://developer.mozilla.org/fr/docs/JavaScript_Guide/Op%C3%A9rateurs/Op%C3%A9rateurs_sp%C3%A9ciaux)
*/
var lang = env.locale;
var strPrevious = "";
var strNext = "";
var s_PreviousNext = mdn.localString({
"en-US": ["« Previous", "Next »"],
"es" : ["« Anterior", "Siguiente »"],
"fr" : ["« Précédent", "Suivant »"],
"ja" : ["« 前のページ", "次のページ »"],
"ko" : ["« 이전", "다음 »"],
"ru" : ["« Предыдущая статья", "Следующая статья »"],
"zh-CN": ["« 上一页", "下一页 »"],
"zh-TW": ["« 前頁", "次頁 »"]
});
if ($0) {
strPrevious = '<li><a class="button secondary" href="/' + lang + '/docs/' + $0.replace(/ /g, '_') + '">' + s_PreviousNext[0] + '</a></li>';
}
if ($1) {
strNext = '<li><a class="button secondary" href="/' + lang + '/docs/' + $1.replace(/ /g, '_') + '">' + s_PreviousNext[1] + '</a></li>';
}
/* two parameters: path of previous page and path to next */
/* Calls PreviousMenuNext to avoid duplication of translations */
%>
<ul class="prev-next">
<%- strPrevious %>
<%- strNext %>
</ul>
<%- await template("PreviousMenuNext", [$0, $1]) %>
2 changes: 1 addition & 1 deletion kumascript/macros/ReadOnlyInline.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ var title = mdn.localString({
"zh-CN": "该属性的值无法更改",
});
%>
<span title="<%= title %>" class="badge inline readonly"><%= str %></span>
<span class="badge inline readonly" title="<%= title %>"><%= str %></span>
2 changes: 1 addition & 1 deletion kumascript/macros/SVGAttr.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ var slug = mdn.localString({
var URL = "/" + env.locale + "/docs/Web/SVG/" + slug + "/" + $0;
%>
<code><a href="<%- URL %>"><%= $0 %></a></code>
<a href="<%- URL %>"><code><%= $0 %></code></a>
14 changes: 7 additions & 7 deletions kumascript/src/api/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
*/
import sanitizeFilename from "sanitize-filename";
import * as cheerio from "cheerio";
import chalk from "chalk";

const H1_TO_H6_TAGS = new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
const HEADING_TAGS = new Set([...H1_TO_H6_TAGS, "hgroup"]);
const INJECT_SECTION_ID_TAGS = new Set([
...HEADING_TAGS,
"section",
"div",
"dt",
]);
const INJECT_SECTION_ID_TAGS = new Set([...HEADING_TAGS, "section", "dt"]);
const LIVE_SAMPLE_PARTS = ["html", "css", "js"];
const SECTION_ID_DISALLOWED = /["#$%&+,/:;=?@[\]^`{|}~')(\\]/g;

Expand Down Expand Up @@ -130,7 +126,6 @@ function collectClosestCode($start) {
];
});
if (pairs.some(([, code]) => !!code)) {
$start.prop("title", $level.first(":header").text());
return Object.fromEntries(pairs);
}
}
Expand Down Expand Up @@ -316,6 +311,11 @@ export class HTMLTool {
// We're here because we can't find the sectionID, so instead we're going
// to find the live-sample iframe by its id (iframeID, NOT sectionID), and
// then collect the closest blocks of code for the live sample.
console.warn(
chalk.yellow(
`invalid header id in live sample ${sectionID} within ${this.pathDescription}`
)
);
result = collectClosestCode(findSectionStart(this.$, iframeID));
if (!result) {
throw new KumascriptError(
Expand Down
7 changes: 7 additions & 0 deletions kumascript/tests/macros/fixtures/apiref/commonl10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,12 @@
"fr": "Interfaces",
"ja": "インターフェイス",
"es": "Interfaces"
},

"summary": {
"en-US": "The documentation about this has not yet been written; please consider contributing!",
"fr": "Cette documentation n'a pas encore été rédigée, vous pouvez aider en contribuant!",
"ja": "この項目についての文書はまだ書かれていません。書いてみませんか?",
"es": "La documentación acerca de este tema no ha sido escrita todavía. ¡Por favor considera contribuir!"
}
}
2 changes: 1 addition & 1 deletion kumascript/tests/macros/svgattr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describeMacro("SVGAttr", () => {
macro.ctx.env.locale = locale;
return assert.eventually.equal(
macro.call(attr),
`<code><a href="/${locale}/docs/Web/SVG/Attribute/${attr}">${attr}</a></code>`
`<a href="/${locale}/docs/Web/SVG/Attribute/${attr}"><code>${attr}</code></a>`
);
});
}
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
"@codemirror/state": "^6.4.1",
"@codemirror/theme-one-dark": "^6.1.2",
"@fast-csv/parse": "^5.0.2",
"@inquirer/prompts": "^7.0.0",
"@inquirer/prompts": "^7.0.1",
"@lit/react": "^1.0.6",
"@mdn/bcd-utils-api": "^0.0.7",
"@mdn/browser-compat-data": "^5.6.9",
"@mdn/browser-compat-data": "^5.6.10",
"@mozilla/glean": "5.0.3",
"@sentry/node": "^8.35.0",
"@stripe/stripe-js": "^4.9.0",
Expand Down Expand Up @@ -116,9 +116,9 @@
"loglevel": "^1.9.2",
"lru-cache": "^10.4.3",
"md5-file": "^5.0.0",
"mdast-util-from-markdown": "^2.0.1",
"mdast-util-from-markdown": "^2.0.2",
"mdast-util-phrasing": "^4.1.0",
"mdn-data": "^2.11.1",
"mdn-data": "^2.12.0",
"open": "^10.1.0",
"open-editor": "^5.0.0",
"openai": "^4.68.4",
Expand Down Expand Up @@ -147,28 +147,28 @@
"unified": "^11.0.5",
"unist-builder": "^4.0.0",
"unist-util-visit": "^5.0.0",
"web-features": "^2.2.0",
"web-features": "^2.3.0",
"web-specs": "^3.23.0"
},
"devDependencies": {
"@babel/core": "^7.25.8",
"@babel/core": "^7.26.0",
"@babel/eslint-parser": "^7.25.9",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/preset-env": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@mdn/dinocons": "^0.5.5",
"@mdn/minimalist": "^2.0.4",
"@playwright/test": "^1.48.1",
"@playwright/test": "^1.48.2",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@svgr/webpack": "^8.1.0",
"@swc/core": "^1.7.39",
"@swc/core": "^1.7.40",
"@testing-library/react": "^15.0.7",
"@types/async": "^3.2.24",
"@types/cli-progress": "^3.11.6",
"@types/imagemin": "^9.0.0",
"@types/jest": "^29.5.14",
"@types/js-yaml": "^4.0.9",
"@types/mdast": "^4.0.4",
"@types/node": "^18.19.59",
"@types/node": "^18.19.60",
"@types/prismjs": "^1.26.5",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
Expand All @@ -195,7 +195,7 @@
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-jsx-a11y": "^6.10.1",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-n": "^17.11.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^4.6.2",
Expand Down Expand Up @@ -260,7 +260,7 @@
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typescript": "^5.6.3",
"typescript-eslint": "^8.11.0",
"typescript-eslint": "^8.12.1",
"webpack": "^5.95.0",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^5.1.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
- Learn
- flexbox
---

<h2 id="Flexbox">Flexbox</h2>
<!--
Grab the content of the live samples from a different page. This tests
that the page must be fully rendered before extracting the live samples,
and also tests that prerequisites are handled as part of the rendering
and live-sample-building process.
-->
<div id="Flex_1">{{ Page("Learn/CSS/CSS_layout/Introduction/Flex/Stuff", "Flex_1") }}</div>
<p>{{ EmbedLiveSample('Flex_1', '300', '200') }}</p>
<div id="Flex_2">{{ Page("Learn/CSS/CSS_layout/Introduction/Flex/Stuff", "Flex_2") }}</div>>
<p>{{ EmbedLiveSample('Flex_2', '300', '200') }}</p>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- flexbox
- flow
---

<div>{{LearnSidebar}}</div>

<!--
Expand All @@ -23,27 +24,24 @@
and some from other pages.
-->

<h2 id="Flexbox">Flexbox</h2>
<p>{{ EmbedLiveSample('Flex_1', '300', '200', "", "Learn/CSS/CSS_layout/Introduction/Flex") }}</p>
<p>{{ EmbedLiveSample('Flex_2', '300', '200', "", "Learn/CSS/CSS_layout/Introduction/Flex") }}</p>

<h2 id="Grid_Layout">Grid Layout</h2>
<p>{{ EmbedLiveSample('Grid_1', '300', '330', "", "Learn/CSS/CSS_layout/Introduction/Grid") }}</p>
<div id="Grid_2">
<div class="hidden">
<h6 id="Grid_example_2">Grid example 2</h6>
<div class="hidden">
<h6 id="Grid_example_2">Grid example 2</h6>

<pre class="brush: css hidden"> * {box-sizing: border-box;}
<pre class="brush: css hidden">
* {box-sizing: border-box;}

.wrapper &gt; div {
border-radius: 5px;
background-color: rgb(207,232,220);
padding: 1em;
}
</pre>
</div>
</div>

<pre class="brush: css">.wrapper {
<pre class="brush: css">
.wrapper {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 100px 100px;
Expand All @@ -64,14 +62,17 @@ <h6 id="Grid_example_2">Grid example 2</h6>
grid-row: 2;
grid-column: 3;
}
</pre>
</pre
>

<pre class="brush: html">&lt;div class="wrapper"&gt;
<pre class="brush: html">
&lt;div class="wrapper"&gt;
&lt;div class="box1"&gt;One&lt;/div&gt;
&lt;div class="box2"&gt;Two&lt;/div&gt;
&lt;div class="box3"&gt;Three&lt;/div&gt;
&lt;/div&gt;
</pre>
</pre
>
</div>

<p>{{ EmbedLiveSample('Grid_2', '300', '330') }}</p>
<p>{{ EmbedLiveSample('Grid_Layout', '300', '330') }}</p>
Loading

0 comments on commit 69154b5

Please sign in to comment.