Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 9.0.7-wip
* Add built-in CSS styling for the <example> HTML tag to support highlighted code examples.

## 9.0.6
* Require analyzer 13.0.2 APIs.
* Introduce the {@example} directive for embedding external files, with support for extracting specific code blocks via #region tags.
Expand Down
2 changes: 1 addition & 1 deletion dartdoc_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dartdoc:
linkToSource:
root: '.'
uriTemplate: 'https://github.com/dart-lang/dartdoc/blob/v9.0.6/%f%#L%l%'
uriTemplate: 'https://github.com/dart-lang/dartdoc/blob/v9.0.7-wip/%f%#L%l%'
8 changes: 4 additions & 4 deletions lib/resources/docs.dart.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/resources/styles.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/src/render/documentation_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ final _allowedElements = <String>{
'SPAN',
'TIME',
'WBR',
'CALLOUT-BOX',
};

// Inspired by the set of HTML attributes allowed in GFM.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const packageVersion = '9.0.6';
const packageVersion = '9.0.7';
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: dartdoc
version: 9.0.6
version: 9.0.7-wip
description: A non-interactive HTML documentation generator for Dart source code.
repository: https://github.com/dart-lang/dartdoc

Expand Down
6 changes: 6 additions & 0 deletions test/end2end/model_special_cases_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ void main() {
Class classWithHtml;
late final Method blockHtml;
late final Method inlineHtml;
late final Method customExampleHtml;
late final PackageGraph packageGraph;
late final Library exLibrary;

Expand All @@ -198,6 +199,7 @@ void main() {
classWithHtml = exLibrary.classes.named('SanitizableHtml');
blockHtml = classWithHtml.instanceMethods.named('blockHtml');
inlineHtml = classWithHtml.instanceMethods.named('inlineHtml');
customExampleHtml = classWithHtml.instanceMethods.named('customExampleHtml');
for (var modelElement in packageGraph.localPublicLibraries
.expand((l) => l.allModelElements)) {
// Accessing this getter triggers documentation-processing.
Expand Down Expand Up @@ -240,6 +242,10 @@ void main() {
test('removes bad block HTML', () {
expect(blockHtml.documentationAsHtml, isNot(contains('bad-idea')));
});

test('can have callout-box HTML', () {
expect(customExampleHtml.documentationAsHtml, contains('<callout-box>'));
});
});

group('HTML Injection when allowed', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ abstract class SanitizableHtml {
///
/// This is a <a href="javascript:alert('bad-idea');">bad</a> link.
void inlineHtml();

/// Tests custom callout-box tags
///
/// <callout-box>A fine example</callout-box>
void customExampleHtml();
}
2 changes: 1 addition & 1 deletion web/sig.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
67C19593977E0B284E58447F539D330E
AE937D022C3148CCD0F12D78DF21EA08
21 changes: 21 additions & 0 deletions web/styles/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,24 @@ th,
td {
padding: 8px;
}

callout-box {
padding: 10px;
overflow: auto;
display: block;
unicode-bidi: isolate;
margin: 1em 0;
background-color: var(--callout-box-bg-color);
}

callout-box p {
margin: 8px 40px 12px 8px;
}

callout-box pre {
margin: 0;
}

callout-box code.hljs {
max-height: 500px;
Comment thread
szakarias marked this conversation as resolved.
Resolved
}
4 changes: 4 additions & 0 deletions web/styles/_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
img[src$="#gh-dark-mode-only"] {
display: none;
}

--callout-box-bg-color: rgb(215, 235, 252);
}

.dark-theme {
Expand Down Expand Up @@ -109,6 +111,8 @@
img[src$="#gh-light-mode-only"] {
display: none;
}

--callout-box-bg-color: rgb(30, 40, 51);
}

#theme-button {
Expand Down
Loading