From 858002fc83942847c516bc44f314c12af3622640 Mon Sep 17 00:00:00 2001 From: Istvan Soos Date: Thu, 6 Jun 2024 18:10:33 +0200 Subject: [PATCH 1/2] CSS refactoring: dartdoc.scss, separation of third_party and customization. --- .gitignore | 2 ++ app/lib/dartdoc/dartdoc_page.dart | 17 +---------- app/lib/frontend/static_files.dart | 24 ++++++++------- app/test/dartdoc/dartdoc_page_test.dart | 4 +-- app/test/frontend/static_files_test.dart | 6 ++++ .../documentation/oxygen/1.0.0/index.html | 4 +-- .../oxygen/1.0.0/oxygen/MainClass-class.html | 4 +-- .../1.0.0/oxygen/MainClass/MainClass.html | 4 +-- .../oxygen/1.0.0/oxygen/MainClass/text.html | 4 +-- .../1.0.0/oxygen/MainClass/toLowerCase.html | 4 +-- .../1.0.0/oxygen/MainClass/toString.html | 4 +-- .../oxygen/1.0.0/oxygen/TypeEnum.html | 4 +-- .../1.0.0/oxygen/TypeEnum/TypeEnum.html | 4 +-- .../oxygen/TypeEnum/values-constant.html | 4 +-- .../oxygen/1.0.0/oxygen/main.html | 4 +-- .../oxygen/1.0.0/oxygen/oxygen-library.html | 4 +-- .../documentation/oxygen/2.0.0/index.html | 4 +-- .../oxygen/2.0.0/oxygen/MainClass-class.html | 4 +-- .../2.0.0/oxygen/MainClass/MainClass.html | 4 +-- .../oxygen/2.0.0/oxygen/MainClass/text.html | 4 +-- .../2.0.0/oxygen/MainClass/toLowerCase.html | 4 +-- .../2.0.0/oxygen/MainClass/toString.html | 4 +-- .../oxygen/2.0.0/oxygen/TypeEnum.html | 4 +-- .../2.0.0/oxygen/TypeEnum/TypeEnum.html | 4 +-- .../oxygen/TypeEnum/values-constant.html | 4 +-- .../oxygen/2.0.0/oxygen/main.html | 4 +-- .../oxygen/2.0.0/oxygen/oxygen-library.html | 4 +-- .../documentation/oxygen/latest/index.html | 4 +-- .../oxygen/latest/oxygen/MainClass-class.html | 4 +-- .../latest/oxygen/MainClass/MainClass.html | 4 +-- .../oxygen/latest/oxygen/MainClass/text.html | 4 +-- .../latest/oxygen/MainClass/toLowerCase.html | 4 +-- .../latest/oxygen/MainClass/toString.html | 4 +-- .../oxygen/latest/oxygen/TypeEnum.html | 4 +-- .../latest/oxygen/TypeEnum/TypeEnum.html | 4 +-- .../oxygen/TypeEnum/values-constant.html | 4 +-- .../oxygen/latest/oxygen/main.html | 4 +-- .../oxygen/latest/oxygen/oxygen-library.html | 4 +-- pkg/web_css/build.sh | 5 ++++ pkg/web_css/lib/dartdoc.scss | 16 ++++++++++ pkg/web_css/lib/src/_themes.scss | 30 +++++++++++++++++++ pkg/web_css/lib/style.scss | 3 +- third_party/css/github-markdown.css | 27 ----------------- 43 files changed, 111 insertions(+), 155 deletions(-) create mode 100644 pkg/web_css/lib/dartdoc.scss create mode 100644 pkg/web_css/lib/src/_themes.scss diff --git a/.gitignore b/.gitignore index e8793163da..70605f9c85 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,8 @@ build/ *.sum # Ignore files built when the server is started +/static/css/dartdoc.css +/static/css/dartdoc.css.map /static/css/style.css /static/css/style.css.map /static/js/script.dart.js diff --git a/app/lib/dartdoc/dartdoc_page.dart b/app/lib/dartdoc/dartdoc_page.dart index 6c210df8e2..de365ce2ed 100644 --- a/app/lib/dartdoc/dartdoc_page.dart +++ b/app/lib/dartdoc/dartdoc_page.dart @@ -110,21 +110,6 @@ extension DartDocPageRender on DartDocPage { if (!options.isLatestStable) d.meta(rel: 'alternate', href: options.latestStableDocumentationUrl), d.link(rel: 'preconnect', href: 'https://fonts.gstatic.com'), - // HACK: This is not part of dartdoc - d.link( - rel: 'stylesheet', - type: 'text/css', - href: staticUrls.githubMarkdownCss), - // TODO: Consider using same github.css we use on pub.dev - d.link( - rel: 'stylesheet', - type: 'text/css', - href: staticUrls.dartdocGithubCss), - if (activeConfiguration.isStaging) - d.link( - rel: 'stylesheet', - type: 'text/css', - href: staticUrls.getAssetUrl('/static/css/staging-ribbon.css')), d.link( rel: 'stylesheet', href: @@ -136,7 +121,7 @@ extension DartDocPageRender on DartDocPage { 'https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0', ), - d.link(rel: 'stylesheet', href: staticUrls.dartdocStylesCss), + d.link(rel: 'stylesheet', href: staticUrls.dartdocCss), d.link(rel: 'icon', href: staticUrls.smallDartFavicon), ]); diff --git a/app/lib/frontend/static_files.dart b/app/lib/frontend/static_files.dart index 613941e75f..4319d64734 100644 --- a/app/lib/frontend/static_files.dart +++ b/app/lib/frontend/static_files.dart @@ -240,11 +240,7 @@ class StaticUrls { late final pubDevLogoSvg = getAssetUrl('/static/img/pub-dev-logo.svg'); late final defaultProfilePng = getAssetUrl( '/static/img/material-icon-twotone-account-circle-white-24dp.png'); - late final githubMarkdownCss = getAssetUrl('/static/css/github-markdown.css'); - late final dartdocGithubCss = - getAssetUrl('/static/dartdoc/resources/github.css'); - late final dartdocStylesCss = - getAssetUrl('/static/dartdoc/resources/styles.css'); + late final dartdocCss = getAssetUrl('/static/css/dartdoc.css'); late final dartdocScriptJs = getAssetUrl('/static/dartdoc/resources/docs.dart.js'); late final dartdochighlightJs = @@ -331,11 +327,19 @@ Future updateLocalBuiltFilesIfNeeded() async { final webCssDir = Directory(resolveWebCssDirPath()); final webCssLastModified = await _detectLastModified(webCssDir); - final styleCss = File(path.join(staticDir.path, 'css', 'style.css')); - final styleCssExists = await styleCss.exists(); - final styleCssLastModified = - styleCssExists ? await styleCss.lastModified() : null; - if (!styleCssExists || (styleCssLastModified!.isBefore(webCssLastModified))) { + + Future cssNeedsUpdate(String filename) async { + final styleCss = File(path.join(staticDir.path, 'css', filename)); + final styleCssExists = await styleCss.exists(); + final styleCssLastModified = + styleCssExists ? await styleCss.lastModified() : null; + return !styleCssExists || + (styleCssLastModified!.isBefore(webCssLastModified)); + } + + final needsCssBuild = (await cssNeedsUpdate('style.css')) || + (await cssNeedsUpdate('dartdoc.css')); + if (needsCssBuild) { _logger.info('Building pkg/web_css'); await updateWebCssBuild(); } diff --git a/app/test/dartdoc/dartdoc_page_test.dart b/app/test/dartdoc/dartdoc_page_test.dart index eb3d715254..e3e101b08c 100644 --- a/app/test/dartdoc/dartdoc_page_test.dart +++ b/app/test/dartdoc/dartdoc_page_test.dart @@ -134,7 +134,7 @@ void main() { _removeSharedXmlNodes(fileXmlRoot, renderedXmlDoc); // cleanup differences - for (final link in ['/styles.css', '/favicon.png']) { + for (final link in ['/styles.css', '/github.css', '/favicon.png']) { fileXmlRoot.descendantElements .firstWhere((e) => e.localName == 'link' && @@ -149,7 +149,7 @@ void main() { renderedHead.childElements .firstWhereOrNull((e) => e.getAttribute('content') == 'noindex') ?.remove(); - expect(renderedHead.children, hasLength(7)); + expect(renderedHead.children, hasLength(6)); for (final c in [...renderedHead.childElements]) { c.remove(); } diff --git a/app/test/frontend/static_files_test.dart b/app/test/frontend/static_files_test.dart index 0d7515f120..cafde7113c 100644 --- a/app/test/frontend/static_files_test.dart +++ b/app/test/frontend/static_files_test.dart @@ -130,6 +130,7 @@ void main() { ..remove('/static/js/survey-helper.js') // debug-helper files are served, but not referenced ..removeAll([ + '/static/css/dartdoc.css.map', '/static/css/style.css.map', '/static/js/script.dart.js.deps', '/static/js/script.dart.js.info.json', @@ -161,6 +162,11 @@ void main() { '/static/css/github-markdown.css', '/static/highlight/github.css', ]) + // dartdoc files included through dartdoc.scss + ..removeAll([ + '/static/dartdoc/resources/github.css', + '/static/dartdoc/resources/styles.css', + ]) // dartdoc files not used, or included through javascript ..removeAll([ '/static/dartdoc/resources/favicon.png', diff --git a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/index.html b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/index.html index 796e2080b1..e951a08a04 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/index.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/index.html @@ -13,11 +13,9 @@ - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass-class.html b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass-class.html index b3b4fb6d61..130493f07b 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass-class.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass-class.html @@ -13,11 +13,9 @@ - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/MainClass.html b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/MainClass.html index 8f22d270d9..dde483ac6b 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/MainClass.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/MainClass.html @@ -13,11 +13,9 @@ - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/text.html b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/text.html index eebf6798c6..146f76b125 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/text.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/text.html @@ -13,11 +13,9 @@ - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/toLowerCase.html b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/toLowerCase.html index b26c6d34cb..15ec9ef7c8 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/toLowerCase.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/toLowerCase.html @@ -13,11 +13,9 @@ - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/toString.html b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/toString.html index 28321ce524..04dc8c5071 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/toString.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/MainClass/toString.html @@ -13,11 +13,9 @@ - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum.html b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum.html index f06ba03263..6ed6d5345e 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum.html @@ -13,11 +13,9 @@ - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum/TypeEnum.html b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum/TypeEnum.html index 85a3641a2f..615400ef2a 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum/TypeEnum.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum/TypeEnum.html @@ -13,11 +13,9 @@ - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum/values-constant.html b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum/values-constant.html index e88d1d5c64..98a5100446 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum/values-constant.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/TypeEnum/values-constant.html @@ -13,11 +13,9 @@ - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/main.html b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/main.html index ea4ab64be5..7a8c14861d 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/main.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/main.html @@ -13,11 +13,9 @@ - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/oxygen-library.html b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/oxygen-library.html index 62b80ebf47..a9dbb852ef 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/oxygen-library.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/1.0.0/oxygen/oxygen-library.html @@ -13,11 +13,9 @@ - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/index.html b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/index.html index 98bd3983d5..a9b8475b7d 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/index.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/index.html @@ -11,11 +11,9 @@ oxygen - Dart API docs - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass-class.html b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass-class.html index 98147776fb..daf1233ed9 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass-class.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass-class.html @@ -11,11 +11,9 @@ MainClass class - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/MainClass.html b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/MainClass.html index 04c8e587c9..bf502a52c8 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/MainClass.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/MainClass.html @@ -12,11 +12,9 @@ MainClass constructor - MainClass - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/text.html b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/text.html index 32b076b724..47d64b3b97 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/text.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/text.html @@ -12,11 +12,9 @@ text property - MainClass class - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/toLowerCase.html b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/toLowerCase.html index bee5300c50..b8ef47add0 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/toLowerCase.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/toLowerCase.html @@ -12,11 +12,9 @@ toLowerCase method - MainClass class - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/toString.html b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/toString.html index f488a973b5..f2f1c79605 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/toString.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/MainClass/toString.html @@ -12,11 +12,9 @@ toString method - MainClass class - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/TypeEnum.html b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/TypeEnum.html index 669f3b6625..af0c631060 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/TypeEnum.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/TypeEnum.html @@ -11,11 +11,9 @@ TypeEnum enum - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/TypeEnum/TypeEnum.html b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/TypeEnum/TypeEnum.html index 0aa158a015..7f9cf4a555 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/TypeEnum/TypeEnum.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/TypeEnum/TypeEnum.html @@ -12,11 +12,9 @@ TypeEnum constructor - TypeEnum - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/TypeEnum/values-constant.html b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/TypeEnum/values-constant.html index 35ea21332c..799cbaca80 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/TypeEnum/values-constant.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/TypeEnum/values-constant.html @@ -12,11 +12,9 @@ values constant - TypeEnum enum - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/main.html b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/main.html index dffc47be6f..8dbafb65b1 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/main.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/main.html @@ -11,11 +11,9 @@ main function - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/oxygen-library.html b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/oxygen-library.html index f267e7e710..9938e7b954 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/oxygen-library.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/2.0.0/oxygen/oxygen-library.html @@ -11,11 +11,9 @@ oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/latest/index.html b/app/test/task/testdata/goldens/documentation/oxygen/latest/index.html index 200d2c9934..581c8a041b 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/latest/index.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/latest/index.html @@ -11,11 +11,9 @@ oxygen - Dart API docs - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass-class.html b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass-class.html index a23a399179..8ed64ea505 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass-class.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass-class.html @@ -11,11 +11,9 @@ MainClass class - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/MainClass.html b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/MainClass.html index 7c173b8538..77e23c56b6 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/MainClass.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/MainClass.html @@ -12,11 +12,9 @@ MainClass constructor - MainClass - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/text.html b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/text.html index 5aa56037de..9239bfd928 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/text.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/text.html @@ -12,11 +12,9 @@ text property - MainClass class - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/toLowerCase.html b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/toLowerCase.html index 8f17620d03..3da02812ec 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/toLowerCase.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/toLowerCase.html @@ -12,11 +12,9 @@ toLowerCase method - MainClass class - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/toString.html b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/toString.html index b146daad10..d5eb1c94f3 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/toString.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/MainClass/toString.html @@ -12,11 +12,9 @@ toString method - MainClass class - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/TypeEnum.html b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/TypeEnum.html index bb3c4fa4a8..9942a9764d 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/TypeEnum.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/TypeEnum.html @@ -11,11 +11,9 @@ TypeEnum enum - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/TypeEnum/TypeEnum.html b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/TypeEnum/TypeEnum.html index c5b3662867..e44f01e4d5 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/TypeEnum/TypeEnum.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/TypeEnum/TypeEnum.html @@ -12,11 +12,9 @@ TypeEnum constructor - TypeEnum - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/TypeEnum/values-constant.html b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/TypeEnum/values-constant.html index 36c1faaa4d..017ec24347 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/TypeEnum/values-constant.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/TypeEnum/values-constant.html @@ -12,11 +12,9 @@ values constant - TypeEnum enum - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/main.html b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/main.html index b24134b15d..d2c4c8f77b 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/main.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/main.html @@ -11,11 +11,9 @@ main function - oxygen library - Dart API - - - + diff --git a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/oxygen-library.html b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/oxygen-library.html index bf5f8a8123..c3909f548d 100644 --- a/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/oxygen-library.html +++ b/app/test/task/testdata/goldens/documentation/oxygen/latest/oxygen/oxygen-library.html @@ -11,11 +11,9 @@ oxygen library - Dart API - - - + diff --git a/pkg/web_css/build.sh b/pkg/web_css/build.sh index 56ff08d822..815770ed03 100755 --- a/pkg/web_css/build.sh +++ b/pkg/web_css/build.sh @@ -18,3 +18,8 @@ dart run sass \ --style=compressed \ "${WEB_CSS_DIR}/lib/style.scss" \ "${OUTPUT_DIR}/style.css" + +dart run sass \ + --style=compressed \ + "${WEB_CSS_DIR}/lib/dartdoc.scss" \ + "${OUTPUT_DIR}/dartdoc.css" diff --git a/pkg/web_css/lib/dartdoc.scss b/pkg/web_css/lib/dartdoc.scss new file mode 100644 index 0000000000..882c0beff0 --- /dev/null +++ b/pkg/web_css/lib/dartdoc.scss @@ -0,0 +1,16 @@ +/* Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file + for details. All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. */ + +// Include third-party CSS into a single output file +// to reduce the number of HTTP requests. + +// Note: this is not part of dartdoc +@use '../../../third_party/css/github-markdown.css'; + +// TODO: Consider using same github.css we use on pub.dev +@use '../../../third_party/dartdoc/resources/github.css'; +@use '../../../third_party/dartdoc/resources/styles.css'; +@use '../../../static/css/staging-ribbon.css'; + +@import 'src/_themes'; diff --git a/pkg/web_css/lib/src/_themes.scss b/pkg/web_css/lib/src/_themes.scss new file mode 100644 index 0000000000..d9027424bf --- /dev/null +++ b/pkg/web_css/lib/src/_themes.scss @@ -0,0 +1,30 @@ +/* Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file + for details. All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. */ + +/* Note: light-theme was added to prevent non-visible table text in dartdoc's dark mode. */ +.light-theme .markdown-body table tr { + background-color: #fff; + border-top: 1px solid #c6cbd1; +} + +/* Note: light-theme was added to prevent non-visible table text in dartdoc's dark mode. */ +.light-theme .markdown-body table tr:nth-child(2n) { + background-color: #f6f8fa; +} + +/* Note: light-theme was added to prevent non-visible table text in dartdoc's dark mode. */ +.light-theme .markdown-body .highlight pre, +.light-theme .markdown-body pre { + background-color: #f6f8fa; +} +.dark-theme .markdown-body pre { + /* TODO(https://github.com/dart-lang/pub-dev/issues/7101): Investigate if this should be fixed in dartdoc's styles.css: the dark theme is not applied there. */ + background-color: inherit; +} + +.dark-theme .hljs .hljs-deletion, +.dark-theme .hljs .hljs-addition { + /* TODO(https://github.com/dart-lang/pub-dev/issues/7101): Investigate if this should be fixed in dartdoc's styles.css: the dark theme is not applied there. */ + color: black; +} diff --git a/pkg/web_css/lib/style.scss b/pkg/web_css/lib/style.scss index cc2c93beb2..1dc8fff7c3 100644 --- a/pkg/web_css/lib/style.scss +++ b/pkg/web_css/lib/style.scss @@ -20,4 +20,5 @@ @import 'src/_scores'; @import 'src/_search'; @import 'src/_tags'; -@import 'src/topics'; +@import 'src/_themes'; +@import 'src/_topics'; diff --git a/third_party/css/github-markdown.css b/third_party/css/github-markdown.css index 0845270cb0..18495af3f6 100644 --- a/third_party/css/github-markdown.css +++ b/third_party/css/github-markdown.css @@ -212,17 +212,6 @@ border: 1px solid #dfe2e5; } -/* Note: light-theme was added to prevent non-visible table text in dartdoc's dark mode. */ -.light-theme .markdown-body table tr { - background-color: #fff; - border-top: 1px solid #c6cbd1; -} - -/* Note: light-theme was added to prevent non-visible table text in dartdoc's dark mode. */ -.light-theme .markdown-body table tr:nth-child(2n) { - background-color: #f6f8fa; -} - .markdown-body table img { background-color: transparent; } @@ -384,22 +373,6 @@ border-radius: 3px; } -/* Note: light-theme was added to prevent non-visible table text in dartdoc's dark mode. */ -.light-theme .markdown-body .highlight pre, -.light-theme .markdown-body pre { - background-color: #f6f8fa; -} -.dark-theme .markdown-body pre { - /* TODO(https://github.com/dart-lang/pub-dev/issues/7101): Investigate if this should be fixed in dartdoc's styles.css: the dark theme is not applied there. */ - background-color: inherit; -} - -.dark-theme .hljs .hljs-deletion, -.dark-theme .hljs .hljs-addition { - /* TODO(https://github.com/dart-lang/pub-dev/issues/7101): Investigate if this should be fixed in dartdoc's styles.css: the dark theme is not applied there. */ - color: black; -} - .markdown-body pre code, .markdown-body pre tt { display: inline; From 18adec8f8c77117a3217ef42518693de764ea4be Mon Sep 17 00:00:00 2001 From: Istvan Soos Date: Thu, 6 Jun 2024 18:23:54 +0200 Subject: [PATCH 2/2] fix test --- app/lib/frontend/static_files.dart | 1 + app/test/dartdoc/dartdoc_page_test.dart | 1 + 2 files changed, 2 insertions(+) diff --git a/app/lib/frontend/static_files.dart b/app/lib/frontend/static_files.dart index 4319d64734..e752d3db5d 100644 --- a/app/lib/frontend/static_files.dart +++ b/app/lib/frontend/static_files.dart @@ -118,6 +118,7 @@ class StaticFileCache { // deployment process. Normally page rendering checks their existence, // and fails when they are missing. By listing these here, the build // is no longer a strict requirement, and tests can be run without it. + '/static/css/dartdoc.css', '/static/css/style.css', '/static/js/script.dart.js', }; diff --git a/app/test/dartdoc/dartdoc_page_test.dart b/app/test/dartdoc/dartdoc_page_test.dart index e3e101b08c..ddf00a98a8 100644 --- a/app/test/dartdoc/dartdoc_page_test.dart +++ b/app/test/dartdoc/dartdoc_page_test.dart @@ -62,6 +62,7 @@ void main() { scopedTest( 'run dartdoc', () async { + registerStaticFileCacheForTest(StaticFileCache.forTests()); final pr = await toolEnv.dartdoc(pkgDir, docDir, usesFlutter: false); expect(pr.exitCode, 0);