Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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',
'EXAMPLE',
Comment thread
szakarias marked this conversation as resolved.
Resolved
};

// 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 example HTML', () {
expect(customExampleHtml.documentationAsHtml, contains('<example>'));
});
});

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 example tags
///
/// <example>A fine example</example>
void customExampleHtml();
}
2 changes: 1 addition & 1 deletion web/sig.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
67C19593977E0B284E58447F539D330E
7848C06D1465C90600DD56527148A5AB
20 changes: 20 additions & 0 deletions web/styles/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,23 @@ th,
td {
padding: 8px;
}

example {
padding: 10px;
overflow: auto;
display: block;
unicode-bidi: isolate;
margin: 1em 0;
}
Comment thread
szakarias marked this conversation as resolved.
Resolved

example p {
margin: 8px 40px 12px 8px;
}

example pre {
margin: 0;
}

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

example {
background-color: rgb(215, 235, 252);
}
Comment thread
szakarias marked this conversation as resolved.
Resolved
}

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

example {
background-color: rgb(30, 40, 51);
}
Comment thread
szakarias marked this conversation as resolved.
Resolved
}

#theme-button {
Expand Down
Loading