Page MenuHomePhabricator

API action=parse&prop=headhtml returns more than just the <head> element: Fix documentation
Closed, ResolvedPublic

Description

action=parse&prop=headhtml is supposed to give "parsed <head> of the page". Instead, it returns something like

<!DOCTYPE html>
<html ...>
<head>
...
</head>
<body ...>

when I would have just expected the <head> element and its contents.

I'm not too sure what "parsed" means in this context, either. What would an unparsed <head> look like?

This should either be fixed (which would clearly be a breaking change), or the documentation corrected to match the actual output. It's not clear from the comments on T20608 what the intended output was at the outset.

Event Timeline

The option seems to correspond to whatever OutputPage::headElement() returns, so the documentation should be fixed to reflect that.

Aklapper renamed this task from API action=parse&prop=headhtml returns more than just the <head> element to API action=parse&prop=headhtml returns more than just the <head> element: Fix documentation.Jul 7 2016, 2:13 PM

@Anomie @TTO I'm having a hard time phrasing a description of the response. How does "Gives the html content that comes before the <body> of the page" sound?

@jeropbrenda: Sounds still incorrect because the <body ...> tag itself is actually included. :)
Please see yourself: https://www.mediawiki.org/w/api.php?action=parse&format=jsonfm&page=MediaWiki&prop=text&prop=headhtml

Maybe use the @return doc value in https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/OutputPage.php$3171-3176 and add and opening "<body>" to it?

@Aklapper Thanks a bunch:)
How does Gives the doctype, opening <html>, head element and opening <body> of the page sound?

@jeropbrenda: Something like Returns the doctype, opening <html>, head element and opening <body> of the page sounds good to me (but note that I'm not a maintainer, that's just my personal opinion).

Change 496115 had a related patch set uploaded (by Jeropbrendawm; owner: Jeropbrendawm):
[mediawiki/core@master] Edit API documentation for action=parse&prop=headhtml

https://gerrit.wikimedia.org/r/496115

Change 496115 merged by jenkins-bot:
[mediawiki/core@master] Correct API documentation for action=parse&prop=headhtml

https://gerrit.wikimedia.org/r/496115