Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move import.meta from Statements to Operators/Expressions #17547

Merged
merged 1 commit into from
Jun 24, 2022

Conversation

Josh-Cena
Copy link
Member

Summary

See #17402 (comment)

Motivation

Supporting details

Related issues

Metadata

  • Adds a new document
  • Rewrites (or significantly expands) a document
  • Fixes a typo, bug, or other error

@Josh-Cena Josh-Cena requested review from a team as code owners June 22, 2022 13:31
@Josh-Cena Josh-Cena requested review from wbamberg and removed request for a team June 22, 2022 13:31
@github-actions github-actions bot added Content:JS JavaScript docs Content:Other Any docs not covered by another "Content:" label Content:WebAPI Web API docs labels Jun 22, 2022
- import
- import.meta
browser-compat: javascript.statements.import_meta
browser-compat: javascript.operators.import_meta
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Preview URLs

Flaws

Note! 2 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/JavaScript/Reference
Title: JavaScript reference
on GitHub
Flaw count: 2

  • macros:
    • /en-US/docs/Web/JavaScript/Reference/AsyncGeneratorFunction does not exist
    • /en-US/docs/Web/JavaScript/Reference/AsyncGenerator does not exist

URL: /en-US/docs/Web/JavaScript/Reference/Statements
Title: Statements and declarations
on GitHub
Flaw count: 2

  • bad_bcd_links:
    • no explanation!
    • no explanation!

URL: /en-US/docs/Web/JavaScript/Reference/Operators
Title: Expressions and operators
on GitHub
Flaw count: 1

  • bad_bcd_links:
    • no explanation!

URL: /en-US/docs/Web/JavaScript/Reference/Operators/import.meta
Title: import.meta
on GitHub
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: javascript.operators.import_meta

URL: /en-US/docs/Mozilla/Firefox/Releases/62
Title: Firefox 62 for developers
on GitHub
Flaw count: 3

  • macros:
    • /en-US/docs/Web/API/DOMPointInit redirects to /en-US/docs/Web/API/DOMPoint/fromPoint
    • /en-US/docs/Web/API/Navigator/registerContentHandler does not exist
  • broken_links:
    • Can't resolve /en-US/docs/Web/WebDriver/WebElement

External URLs

URL: /en-US/docs/Web/JavaScript/Reference
Title: JavaScript reference
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Statements
Title: Statements and declarations
on GitHub

No external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Statements/import
Title: import
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Operators
Title: Expressions and operators
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Operators/import.meta
Title: import.meta
on GitHub

No new external URLs


URL: /en-US/docs/Web/API/Document/currentScript
Title: Document.currentScript
on GitHub


URL: /en-US/docs/Mozilla/Firefox/Releases/62
Title: Firefox 62 for developers
on GitHub

No new external URLs

@wbamberg
Copy link
Collaborator

@Josh-Cena

I'm currently working on defining "page types" for MDN reference docs. A page type is a front matter key that identifies the "kind of thing" that a particular reference page documents. For example, an instance method. The purpose of this is to be able to apply common treatment to similar pages. For example:

  • we would use it when building a sidebar, for example to collect all the instance methods of an interface
  • we would like to associate it with a kind of template for the things a particular type of page may or must include, so we can lint pages against the template

The main tracking bug for this is at #15539. I think we have a reasonable set of types defined for Web/API (#16255).

But I have questions about the JavaScript documentation: it's not always clear to me (outside "Global Objects" and not even always there) how we currently categorise pages, or how we should. I've made a start on this at #16156, and noted the many things I'm not sure about. Since you seem to understand the taxonomy of things in JS I'd like to hear what you think we should do here.

I want this to be a pragmatic exercise: that is, I want to define page types that make distinctions that are important to our purposes, not just for the sake of it. "Our purposes" here is a little vague but includes things like wanting to list different kinds of thing in different places in the sidebar (or other nav elements like landing pages), or wanting to allow/mandate different page components in different kinds of thing.

So if you had thoughts on what would be a sensible taxonomy for our JavaScript docs I would love to hear them.

@Josh-Cena
Copy link
Member Author

Josh-Cena commented Jun 23, 2022

Oh, I didn't realize #16156 existed...

IMO, the current categorization is quite logical. I would speak purely in terms of taxonomy, disregarding whether that fits reader intuition, how the current organization works:

x is a "Global object" iff Object.hasOwn(globalThis, "x"). They are also all listed under section 19 of ECMA262 (plus some in alternative specs, like Intl or WebAssembly maybe).

Not distinguishing between "operators" and "expressions" is a quite clever move. "Operators" aren't a super well-defined construct. For example, some call ?. the "optional chaining operator", others think it's just a syntax. I do agree that seeing "Reference/Operators/new.target" looks a bit off since it's definitely not an operator, so maybe if we are to normalize this we should just make everything "Expression" instead. Speaking of keywords, the trick to deciding whether x is a statement or an expression is whether it can be part of the production of a bigger expression. For example, you can write null + 1, or import.meta.url, which you typically can't do with statements/declarations. (In this regard, I'll probably call "Destructuring assignment" a declaration instead of an expression.)

Anything that can appear on its own line and is not an expression is a declaration/statement. (There's probably a better definition but I'm too lazy to think of one :P)

I would take a deeper look at the renovated page types later; there are some immediately weird things like undefined being "JS function" instead of "JS global property". I agree MDN's current organization is a bit too broad and things like "functions" and "classes" are all over the place. The general direction and categorization in that spreadsheet looks reasonable.

Copy link
Collaborator

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thank you @Josh-Cena !

@wbamberg wbamberg merged commit f1d7d42 into mdn:main Jun 24, 2022
@Josh-Cena Josh-Cena deleted the move-import.meta branch June 25, 2022 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:JS JavaScript docs Content:Other Any docs not covered by another "Content:" label Content:WebAPI Web API docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants