Closed Bug 2068511 Opened 2 months ago Closed 2 months ago

Document the tabbrowser's option defaults and settle on one name for every bag

Categories

(Firefox :: Tabbed Browser, task)

task

Tracking

()

RESOLVED FIXED
157 Branch
Tracking Status
firefox157 --- fixed

People

(Reporter: dao, Assigned: dao)

References

(Blocks 1 open bug)

Details

Attachments

(3 external files)

Tabbrowser.sys.mjs documents its methods' option bags property by property, and the generated gBrowser reference renders each property along with any default the JSDoc declares for it. Two things there disagree with the code.

Twenty-four properties destructure a default. Five say so in their description; the rest leave a caller to read the source to find out what happens when they omit one, and removeTabs animating by default is the likeliest of those to surprise. A literal default belongs in the brackets ([options.animate=true]), where the reference prints it; a computed one belongs in the description, since the brackets cannot be kept in sync with an expression.

The bags are also named inconsistently. Most are options, while setInitialTabTitle, updateBrowserRemotenessByURL, removeCurrentTab, replaceTabWithWindow, replaceTabsWithWindow and duplicateTab take an aOptions or aParams, and removeAllTabsBut documents its destructured bag under aParams. sphinx-js prints that name in front of every property it lists, so the page carries the inconsistency to the reader. The a prefix marks a value the caller supplies, which a bag of named settings is not.

No behavior change: comments, one parameter name per method, and one local variable.

To verify:

./mach doc --no-serve --no-open
./mach lint -l eslint browser/components/tabbrowser/Tabbrowser.sys.mjs

See Also: → 2068532
Assignee: nobody → dao+bmo
Status: NEW → ASSIGNED

They are the three whose option bags the previous commit renames; the other four it touches were already documented. #setTabLabel destructures exactly the three properties setInitialTabTitle now names, so forwarding them individually passes on what the whole bag did. Typing its tab parameter also makes the _labelIsInitialTitle it sets visible to the type checker, hence the declaration beside its _labelIsContentTitle sibling.

Attachment #9635261 - Attachment description: Bug 2068511 - Document what the tabbrowser's options default to. r?kcochrane! → Bug 2068511 - Document the option defaults a caller would not guess. r?kcochrane!
Pushed by dgottwald@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/10c6672b1ab0 https://hg.mozilla.org/integration/autoland/rev/ca948dc7593d Document the option defaults a caller would not guess. r=kcochrane,tabbrowser-reviewers https://github.com/mozilla-firefox/firefox/commit/f2f0fd970eff https://hg.mozilla.org/integration/autoland/rev/07042648f1d3 Rename the tabbrowser's remaining aOptions and aParams bags to options. r=kcochrane,tabbrowser-reviewers https://github.com/mozilla-firefox/firefox/commit/4cbe7df4b97a https://hg.mozilla.org/integration/autoland/rev/768ba66bbf1b Document three public methods that had no JSDoc at all. r=kcochrane,tabbrowser-reviewers
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 157 Branch
QA Whiteboard: [qa-triage-done-c158/b157]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: