• Stars
    star
    1,145
  • Rank 39,320 (Top 0.8 %)
  • Language
    TypeScript
  • License
    Mozilla Public Li...
  • Created almost 5 years ago
  • Updated 6 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The platform code behind MDN Web Docs

Yari

Testing Prod Build

Quickstart

Development on yari involves updating the machinery that renders MDN content or improving the structure and styling of the MDN UI (e.g. the styling of the header). If you are more interested in contributing to the MDN content, you should check out the content repo README instead.

Before you can start working with Yari, you need to:

  1. Install git, Node.js, and Yarn 1.

  2. Fork the MDN content and yari repositories using the Fork button on GitHub.

  3. Clone the forked repositories to your computer using the following commands (replace [your account] with the account you forked the repositories to):

    git clone https://github.com/[your_account]/content.git
    git clone https://github.com/[your_account]/yari.git
    

To run Yari locally, you'll first need to install its dependencies and build the app locally. Do this like so:

cd yari
yarn install

Now copy the .env-dist file to .env:

cp .env-dist .env

If you followed the instructions above and cloned the content repo as a sibling of your yari repo, the CONTENT_ROOT environment variable is already set and Yari will be able to find the content it needs to render.

At this point, you can get started. Run the following lines to compile required files, start the Yari web server running, and open it in your browser:

yarn dev
open http://localhost:3000

If you prefer you can use yarn start, which will re-use any previously compiled files; this is "riskier" but faster. yarn dev always ensures that everything is up-to-date.

The yarn start command also starts a server with slightly different behavior โ€” it doesn't automatically reload when its source code files change, so use with caution.

See also our reviewing guide for information on how to review Yari changes.

Pull request requirements

Firstly, thank you for your interest in contributing to Yari! We do have a few requirements when it comes to pull requests:

  1. Please make use of a feature branch workflow.
  2. We prefer if you use the conventional commits format when making pull requests.
  3. Lastly, we require that all commits are signed. Please see the documentation about signed commits and how to sign yours on GitHub.

Thank you for your understanding! We look forward to your contributions.

How to stay up-to-date

Periodically, the code and the content changes. Make sure you stay up-to-date with something along the following lines (replace yari-origin with whatever you called the remote location of the original yari repo):

git pull yari-origin main
yarn
yarn dev

When you embark on making a change, do it on a new branch, for example git checkout -b my-new-branch.

License

All source code is MPL-2.0.

For content, see its license in the mdn/content repository.

Supported Platforms

yari runs on Linux in CI, and when building for Production.

We also support Windows and MacOS, however we don't aim to proactively catch issues with CI on those platforms. If bugs arise, we welcome issues being filed, or PRs being opened to fix them.

How it works

Yari does a number of things, the most important of which is to render and serve the MDN content found in the content repo. Each document is stored as an index.md (recommended) or index.html file that contains metadata presented as YAML front-matter followed by the document source.

The builder converts these "source files" into "build files" using a CLI tool that iterates over the files, builds the HTML, and lastly packages it up with the front-end code, ready to be served as static files.

Development

The yarn start command encapsulates the front-end dev server (on http://localhost:3000) and the server (on http://localhost:5042).

All the sub-commands of yarn start can be broken down and run individually if you want to work more rapidly.

Setting up $EDITOR

If you configure an environment variable called EDITOR, either on your system as a whole or in the root .env file, it can be used in the development server to link to sources which, when clicked, open in your preferred editor/IDE. For example, in the root of the repo you could run:

echo 'EDITOR=code' >> .env

Now clicking certain links will open files directly in the currently open VS Code IDE (replace code in the above command with a different text editor name if needed, e.g. atom or whatever). To test it, view any document on http://localhost:3000 and click the "Open in your editor" button.

How the server works

The server has two main jobs:

  1. Simulate serving the site (e.g. from a server, S3 or a CDN).
  2. Trigger builds of documents that haven't been built, by URL.

Linting

All JavaScript and TypeScript code needs to be formatted with prettier and it's easy to test this with:

yarn prettier-check

And conveniently, if you're not even interested in what the flaws were, run:

yarn prettier-format

When you ran yarn for the first time (yarn is an alias for yarn install) it automatically sets up a git pre-commit hook that uses lint-staged โ€” a wrapper for prettier that checks only the files in the git commit.

If you have doubts about formatting, submit your pull request anyway. If you have formatting flaws, the pull request checks should catch it.

Upgrading Packages

We maintain the dependencies using Dependabot in GitHub but if you want to manually upgrade them you can use:

yarn upgrade-interactive --latest

Sharing your dev environment with ngrok

ngrok allows you to start an HTTP proxy server from the web into your Yari server. This can be useful for testing your current build using external tools like BrowserStack, WebPageTest, or Google Translate, or to simply show a friend what you're up to. Obviously it'll never be faster than your uplink Internet connection but it should be fairly feature-complete.

  1. Create in account on Ngrok.com
  2. Download the executable
  3. Start your Yari server with yarn start in one terminal
  4. Start the ngrok executable with: /path/to/your/ngrok http 5042

This will display something like this:

Session Status                online
Account                       (Plan: Free)
Version                       2.3.35
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://920ba2108da8.ngrok.io -> http://localhost:5042
Forwarding                    https://920ba2108da8.ngrok.io -> http://localhost:5042

Connections                   ttl     opn     rt1     rt5     p50     p90
                              0       0       0.00    0.00    0.00    0.00

Now, take that "Forwarding" URL (https://920ba2108da8.ngrok.io in this example) and share it.

Building

The server builds content automatically (on-the-fly) when you're viewing pages, but you can pre-emptively build all the content in advance if desired. One potential advantage is that you can get a more complete list of all possible "flaws" across all documents before you even visit them.

The most fundamental CLI command is:

yarn build

What gets built

Every index.html becomes two files:

  • index.html โ€” a fully formed and complete HTML file
  • index.json โ€” the state information React needs to build the page in the client

Flaw checks

When building you can enable specific "flaw checks" and their level of handling. Some flaws are "cosmetic" and some are more severe but they should never block a full build.

More information about how to set flaws can be found in docs/envvars.md.

Essentially, the default is to warn about any flaw and you can see those flaws when using http://localhost:3000. For completed builds, all flaws are ignored. This makes the build faster and there's also no good place to display the flaws in a production-grade build.

In the future, we might make the default flaw level error instead. That means that any new edits to (or creation of) any document will break in continuous integration if there's a single flaw and the onus will be on you to fix it.

Icons and logos

The various formats and sizes of the favicon are generated from the file mdn-web-docs.svg in the repository root. This file is then converted to favicons using realfavicongenerator.net. To generate new favicons, edit or replace the mdn-web-docs.svg file and then re-upload that to realfavicongenerator.net.

Contact

If you want to talk to us, ask questions, and find out more, join the discussion on the MDN Web Docs chat room on Matrix.

Troubleshooting

Some common issues and how to resolve them.

Error: ENOSPC: System limit for number of file watchers reached

There are two options to resolve this.

  1. Disable the watcher via REACT_APP_NO_WATCHER

    echo REACT_APP_NO_WATCHER=true >> .env

  2. Increase max_user_watches:
    See https://github.com/guard/listen#increasing-the-amount-of-inotify-watchers

Error: Cannot find module 'levenary'

We can't know for sure what's causing this error but speculate a bug in how yarn fails to resolve if certain @babel helper libs should install its own sub-dependencies. A sure way to solve it is to run:

rm -fr node_modules
yarn install

Error: listen EADDRINUSE: address already in use :::5042

The default server port :5042 might be in use by another process. To resolve this, you can pick any unused port (e.g., 6000) and run the following:

echo SERVER_PORT=6000 >> .env

More Repositories

1

content

The content behind MDN Web Docs
Markdown
8,869
star
2

learning-area

GitHub repo for the MDN Learning Area.
HTML
6,739
star
3

browser-compat-data

This repository contains compatibility data for Web technologies as displayed on MDN
JSON
4,803
star
4

webextensions-examples

Example Firefox add-ons created using the WebExtensions API
JavaScript
3,972
star
5

dom-examples

Code examples that accompany various MDN DOM and Web API documentation pages
JavaScript
3,198
star
6

web-components-examples

A series of web components examples, related to the MDN web components documentation at https://developer.mozilla.org/en-US/docs/Web/Web_Components.
JavaScript
2,975
star
7

serviceworker-cookbook

It's online. It's offline. It's a Service Worker!
JavaScript
2,767
star
8

kuma

The project that powers MDN.
Python
1,937
star
9

translated-content

The source repository of all translated content for MDN Web Docs
Markdown
1,610
star
10

django-locallibrary-tutorial

Local Library website written in Django; example for the MDN server-side development Django module: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django.
Python
1,535
star
11

web-speech-api

A repository for demos illustrating features of the Web Speech API. See https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API for more details.
JavaScript
1,413
star
12

mdn

Holding repo for MDN Web Docs things
1,263
star
13

webaudio-examples

Code examples that accompany the MDN Web Docs pages relating to Web Audio.
HTML
1,197
star
14

webgl-examples

Code examples that accompany the MDN WebGL documentation
JavaScript
1,196
star
15

express-locallibrary-tutorial

Local Library website written in NodeJS/Express; example for the MDN server-side development NodeJS module: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs.
JavaScript
1,171
star
16

js-examples

Code examples that accompany the MDN JavaScript/ECMAScript documentation
JavaScript
1,090
star
17

webassembly-examples

Code examples that accompany the MDN WebAssembly documentation โ€” see https://developer.mozilla.org/en-US/docs/WebAssembly.
WebAssembly
1,085
star
18

samples-server

MDN samples server; used for samples that can't be hosted in-place on MDN, plus back-end server-side code for samples that need it.
JavaScript
953
star
19

pwa-examples

Examples for progressive web apps.
JavaScript
902
star
20

sw-test

Service Worker test repository. This is a very simple demo to show basic service worker features in action.
JavaScript
756
star
21

simple-web-worker

A simple web worker test.
JavaScript
722
star
22

data

This repository contains general data for Web technologies
JavaScript
714
star
23

interactive-examples

Home of the MDN live code editor interactive examples
HTML
708
star
24

voice-change-o-matic

Web Audio API-powered voice changer and visualizer
JavaScript
705
star
25

css-examples

Code examples that accompany the MDN CSS documentation
HTML
582
star
26

fetch-examples

A repository of Fetch examples. See https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API for the corresponding documentation.
HTML
514
star
27

web-dictaphone

A sample MDN app that uses getUserMedia and MediaRecorder API for recording audio snippets, and The Web Audio API for visualizations.
JavaScript
480
star
28

to-do-notifications

Enhanced version of the to-do app, which stores to-do items via IndexedDB, and then also aims to provide notifications when to-do item deadlines are up, via the Notification and Vibration APIs.
JavaScript
383
star
29

curriculum

MDN front-end developer curriculum
Shell
351
star
30

beginner-html-site

A simple one page website created to help complete beginners learn HTML basics.
HTML
284
star
31

beginner-html-site-scripted

A simple one page website created to help complete beginners learn HTML basics. which in this repo has also had some script added to help beginners learn JavaScript basics.
HTML
255
star
32

violent-theremin

Violent theremin uses the Web Audio API to generate sound, and HTML5 canvas for a bit of pretty visualization. The colours generated depend on the pitch and gain of the current note, which are themselves dependant on the mouse pointer position.
JavaScript
239
star
33

todo-react

Sample todo app built with the React/ReactDOM framework.
JavaScript
215
star
34

django-diy-blog

Basic blog site written in Django (part of MDN Django module assessment).
Python
204
star
35

beginner-html-site-styled

A simple one page website created to help complete beginners learn HTML basics, which in this repo has also been styled to help beginners learn CSS basics. The styling is explained over the course of https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/CSS_basics.
HTML
204
star
36

simple-shared-worker

A simple demo to show shared worker basics.
HTML
198
star
37

sprints

Archived: MDN Web Docs issues are tracked in the content repository.
150
star
38

canvas-raycaster

Using the <canvas> element to do software rendering of a 3D environment with ray-casting
JavaScript
148
star
39

kumascript

Bringing scripting to the wiki bears.
HTML
129
star
40

mdn-community

A place to provide feedback and suggestions for MDN Web Docs
119
star
41

mdn-minimalist

The base Sass for Mozilla Developer based projects and products
SCSS
110
star
42

todo-vue

Sample todo app built with the Vue framework
Vue
90
star
43

html-examples

Code examples that accompany the MDN HTML documentation: https://developer.mozilla.org/en-US/docs/Web/HTML
HTML
88
star
44

advanced-js-fundamentals-ck

This content kit provides learning material to allow intermediate web developers to level up their skills, learning real world techniques to take them past rudimentary syntax towards a solid foundation of skills than can be utilized to create modern web applications. It'll be visual; you'll have fun along the way.
JavaScript
81
star
45

webvr-tests

A set of simple tests for testing WebVR functionality. See https://developer.mozilla.org/en-US/docs/Web/API/WebVR_API for the latest on the documentation.
JavaScript
76
star
46

bob

Builder of Bits aka The MDN Web Docs interactive examples, example builder
TypeScript
74
star
47

headless-examples

Examples to support the MDN resource covering Firefox headless mode โ€” see https://developer.mozilla.org/en-US/Firefox/Headless_mode
JavaScript
71
star
48

developer-portal

The code that generates the MDN Web Docs Developer Portal.
Python
61
star
49

archived-content

Archived MDN Web Docs content that is not actively maintained or frequently built
HTML
58
star
50

voice-change-o-matic-float-data

Web Audio API-powered voice changer and visualizer
JavaScript
56
star
51

mdn-app-template

[UNMAINTAINED] A simple template for writing web apps into, to save you some time when experimenting. Used in MDN web app demos. See https://developer.mozilla.org/en-US/docs/Web/Apps/App_coding_guidelines#Apps_template for more information on what this template contains.
CSS
55
star
52

markdown

MDN Web Docs tool to covert HTML to Markdown
JavaScript
53
star
53

infra

(Deprecated) MDN Web Docs Infrastructure scripts and configuration
HCL
53
star
54

rumba

The clean kuma (๐Ÿค–๐Ÿงน)
Rust
48
star
55

learning-area-pt-br

The MDN Learning Area code examples translated into Brazilian Portuguese.
HTML
42
star
56

wp-promote-mdn

WordPress plugin automatically links keywords and phrases to MDN.
PHP
35
star
57

battery-quickstart-starter-template

[UNMAINTAINED] The starting state of the example built up in the "Your first app" tutorial found in the Mozilla Developer Network open web app Quickstart article.
CSS
33
star
58

crossbrowser-testing-lab

Mozilla's Cross-Browser Testing Lab
32
star
59

indexeddb-examples

Code examples that accompany the MDN IndexedDB documentation
JavaScript
31
star
60

workflows

Reusable GitHub Actions workflows
29
star
61

houdini-examples

CSS Houdini examples relating to MDN content.
HTML
28
star
62

sphinx-theme

(Deprecated) Make Sphinx docs look like MDN
HTML
28
star
63

pab

MDN Web Docs Product Advisory Board
HTML
26
star
64

ansible-jenkins

(Deprecated) Jenkins ansible playbook
Jinja
25
star
65

mdn.dev-2019

(Deprecated) Content for https://mdn.dev
JavaScript
24
star
66

browser-api-demo

A simple demo to show usage of the Mozilla Browser API. See https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API for more details.
JavaScript
23
star
67

addon-sdk-content-scripts

DEPRECATED | Use WebExtensions instead | Add-ons demonstrating how to use content scripts in the Add-on SDK.
JavaScript
23
star
68

stumptown-content

JavaScript
22
star
69

browsercompat

API for browser compatibility data on developer.mozilla.org
Python
22
star
70

web-tech-games

Interactive diagram showing what parts of the web technology stack can used for different purposes when creating games. Includes links to more information about each.
HTML
21
star
71

mdn-dinocons

A scalable set of icons for use across Mozilla Developer websites
20
star
72

insights

The repo that powers MDN Web Docs Insights.
HTML
19
star
73

world-clock

An Ember-based app, built as a sample to demonstrate Ember/Ember CLI and modern web architecture. This goes along with the article series found at https://developer.mozilla.org/en-US/Apps/Build/Modern_web_app_architecture.
JavaScript
19
star
74

fibonacci-worker

A web worker that calculates fibonacci numbers.
HTML
18
star
75

content-kit-template

This is the repo to fork or clone when creating a new MDN Content Kit.
HTML
17
star
76

shared-assets

A repository for media and assets to be used across MDN Web Docs
Mermaid
16
star
77

mdn-fiori

MDN Web Docs Front-End style guide
JavaScript
16
star
78

beginning-programming-content-kit

This is a Content Kit for people who want to teach programming to beginners.
HTML
16
star
79

.github

MDN Web Docs public organization profile
13
star
80

repl-panel

This add-on lets you send remote debugging protocol requests to the debugging server, and displays the response.
JavaScript
13
star
81

short-descriptions

Short descriptions of web platform features, for flexible usage in applications.
JavaScript
12
star
82

audio-channels-demo

A demo to show how the AudioChannels API works, at a basic level
JavaScript
12
star
83

mdn-storybook

UI components for MDN Web Docs
JavaScript
12
star
84

perf-examples

Examples related to MDN performance documentation; see https://developer.mozilla.org/en-US/docs/web/Performance
JavaScript
11
star
85

doc-linter-webextension

Webextension to lint MDN documents
JavaScript
10
star
86

webalyzer

[UNMAINTAINED] Collects web code for analysis and reporting.
Python
10
star
87

battery-quickstart-finished-example

[UNMAINTAINED] The finished version of the example built up in the "Your first app" tutorial found in the Mozilla Developer Network open web app Quickstart article.
JavaScript
10
star
88

community-meetings

A place for agendas and minutes from regular MDN community meetings
9
star
89

whitestorm-demo

A simple demo showing usage of the Whitestorm.js 3D web library.
HTML
9
star
90

browser-compat-toolkit

Toolkit for visualizing and editing MDN's browser compatibility data
JavaScript
9
star
91

e10s-example-addons

Examples showing how to port add-ons to be e10s-compatible
JavaScript
9
star
92

viewsourceconf

Repo for View Source Conference site
HTML
8
star
93

museum

A historic collection of MDN Web Docs content and examples
JavaScript
8
star
94

project-template

A project template to use for new MDN GitHub repositories
7
star
95

imsc-examples

Repository for examples to go along with MDN IMSC documentation.
HTML
7
star
96

todo-react-build

Live version of our sample todo app built with the React/ReactDOM framework.
HTML
7
star
97

retired-content

Content previously, but no longer displayed on MDN Web Docs.
HTML
7
star
98

ai-feedback

Feedback about AI Help
7
star
99

doc-linter-rules

Linting rules used to lint MDN Web Documents
JavaScript
6
star
100

helm-charts

DEPRECATED: Kubernetes Helm charts for the Mozilla Developer Network (MDN).
Smarty
5
star