Go to file
Bartosz Dziewoński 4613ae78e7 Change CommentParser into a service
Goal:
-----
To have a method like CommentParser::parse(), which just takes a node
to parse and a title and returns plain data, so that we don't need to
keep track of the config to construct a CommentParser object (the
required config like content language is provided by services) and
we don't need to keep that object around after parsing.

Changes:
--------
CommentParser.php:
* …is now a service. Constructor only takes services as arguments.
  The node and title are passed to a new parse() method.
* parse() should return plain data, but I split this part to a separate
  patch for ease of review: I49bfe019aa460651447fd383f73eafa9d7180a92.
* CommentParser still cheats and accesses global state in a few places,
  e.g. calling Title::makeTitleSafe or CommentUtils::getTitleFromUrl,
  so we can't turn its tests into true unit tests. This work is left
  for future commits.

LanguageData.php:
* …is now a service, instead of a static class.

Parser.js:
* …is not a real service, but it's changed to behave in a similar way.
  Constructor takes only the required config as argument,
  and node and title are instead passed to a new parse() method.

CommentParserTest.php:
parser.test.js:
* Can be simplified, now that we don't need a useless node and title
  to test internal methods that don't use them.

testUtils.js:
* Can be simplified, now that we don't need to override internal
  ResourceLoader stuff just to change the parser config.

Change-Id: Iadb7757debe000025e52770ca51ebcf24ca8ee66
2022-02-19 19:51:57 +01:00
.phan Merge "Update DiscussionTools phan configuration to match new Parsoid DOM alias config" 2022-01-20 23:34:25 +00:00
i18n Localisation updates from https://translatewiki.net. 2022-02-16 08:12:56 +01:00
images Compress emptystate.svg with svgo 2021-10-04 12:56:20 +01:00
includes Change CommentParser into a service 2022-02-19 19:51:57 +01:00
maintenance Defensive use of dynamic paths in maintenance script 2020-02-20 19:51:07 +01:00
modules Change CommentParser into a service 2022-02-19 19:51:57 +01:00
sql Automatic topic subscriptions (on any edit) 2021-11-15 22:45:42 +01:00
tests Change CommentParser into a service 2022-02-19 19:51:57 +01:00
.eslintignore Fix linting on i18n key order 2021-10-07 17:37:51 +01:00
.eslintrc.json build: Updating ansi-regex to 5.0.1 2021-10-09 07:08:30 +00:00
.gitignore Remove extra blank line from .gitignore file 2020-08-31 15:24:56 +01:00
.gitreview Add .gitreview 2019-10-09 21:18:34 +00:00
.phpcs.xml build: Updating mediawiki/mediawiki-codesniffer to 32.0.0 2020-10-29 10:53:01 +00:00
.stylelintrc.json Remove deprecated dt- classes 2021-03-23 12:39:34 +00:00
CODE_OF_CONDUCT.md build: Updating npm dependencies 2020-01-09 06:43:15 +00:00
composer.json Various code quality tweaks 2022-02-19 19:36:52 +01:00
COPYING Add required files for an extension 2019-10-10 19:42:56 +01:00
DiscussionTools.alias.php Translate Special:TopicSubscriptions to Czech 2021-11-22 16:23:41 +01:00
extension.json Split Data class into ResourceLoaderData and LanguageData 2022-02-19 19:37:34 +01:00
Gruntfile.js eslint: Lint root folder with server rules 2021-10-07 17:37:52 +01:00
package-lock.json build: Update eslint-config-wikimedia to 0.22.1 2022-02-09 13:50:55 +00:00
package.json build: Update eslint-config-wikimedia to 0.22.1 2022-02-09 13:50:55 +00:00