Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ignore] Individual page diagnostic proof of concept #4560

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6,251 changes: 6,251 additions & 0 deletions src/_data/cfe_messages.yaml

Large diffs are not rendered by default.

23,534 changes: 23,534 additions & 0 deletions src/_data/diagnostics.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/_data/side-nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@
permalink: /guides/language/analysis-options
- title: Fixing common type problems
permalink: /guides/language/sound-problems
- title: Diagnostic messages
permalink: /tools/diagnostic-messages
- title: Diagnostics
permalink: /tools/diagnostics
- title: Linter rules
permalink: /tools/linter-rules
- title: Testing & optimization
Expand Down
2 changes: 1 addition & 1 deletion src/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% endif -%}
<div>
{% include shared/page-github-links.html %}
<h1>{{page.title}}</h1>
<h1>{{page.title | name_breaker}}</h1>
</div>
{% include navigation-toc.html id='site-toc--inline' collapsible=true %}
{{ content | inject_anchors }}
Expand Down
9 changes: 9 additions & 0 deletions src/_layouts/diagnostic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: default
---

<p><em>{{page.info.problemMessage}}</em></p>

{{page.info.documentation | markdownify}}

<p>{{page.info}}</p>
93 changes: 93 additions & 0 deletions src/_plugins/diagnostic_page_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
module Jekyll
class DiagnosticPageGenerator < Jekyll::Generator
def generate(site)
diagnostics = site.data['diagnostics']
cfe_messages = site.data['cfe_messages']

new_info = {}

diagnostics.each { |type, messages|
messages.each { |name, info|
name = name.downcase
shared_name = info['sharedName']
if shared_name != nil then
shared_name = shared_name.downcase
shared_info = new_info[shared_name]
if shared_info != nil then
shared_info['problemMessages'].append(info['problemMessage'])
if shared_info['documentation'] == nil then
shared_info['documentation'] = info['documentation']
end
else
new_info[shared_name] = {
'problemMessages' => [info['problemMessage']],
'documentation' => info['documentation']
}
end
else
new_info[name] = {
'problemMessages' => [info['problemMessage']],
'documentation' => info['documentation']
}
end
}
}

cfe_messages.each { |name, info|
if info['documentation'] != nil then
analyzer_name = info['analyzerCode'].gsub('ParserErrorCode.', '').downcase
new_info[analyzer_name] = {
'problemMessages' => [info['problemMessage']],
'documentation' => info['documentation']
}
end
}

new_info.each { |name, info|
site.pages << DiagnosticPage.new(site, name, info)
}
end
end

class DiagnosticPage < Jekyll::PageWithoutAFile
def initialize(site, name, info)
@site = site
@base = site.source
@dir = "/tools/diagnostics"
@basename = name
@ext = '.md'
@name = "#{name}.md"
@content = "#{info['problemMessages'].map{|m| "_#{m}_"}.join("\n\n")}

#{info['documentation']&.gsub(/^####\s/, '### ')}

[constant context]: /tools/diagnostics#constant-context
[definite assignment]: /tools/diagnostics#definite-assignment
[mixin application]: /tools/diagnostics#mixin-application
[override inference]: /tools/diagnostics#override-inference
[part file]: /tools/diagnostics#part-file
[potentially non-nullable]: /tools/diagnostics#potentially-non-nullable
[public library]: /tools/diagnostics#public-library
[ffi]: /guides/libraries/c-interop
[meta-doNotStore]: https://pub.dev/documentation/meta/latest/meta/doNotStore-constant.html
[meta-factory]: https://pub.dev/documentation/meta/latest/meta/factory-constant.html
[meta-immutable]: https://pub.dev/documentation/meta/latest/meta/immutable-constant.html
[meta-internal]: https://pub.dev/documentation/meta/latest/meta/internal-constant.html
[meta-literal]: https://pub.dev/documentation/meta/latest/meta/literal-constant.html
[meta-mustCallSuper]: https://pub.dev/documentation/meta/latest/meta/mustCallSuper-constant.html
[meta-optionalTypeArgs]: https://pub.dev/documentation/meta/latest/meta/optionalTypeArgs-constant.html
[meta-sealed]: https://pub.dev/documentation/meta/latest/meta/sealed-constant.html
[meta-useResult]: https://pub.dev/documentation/meta/latest/meta/useResult-constant.html
[meta-UseResult]: https://pub.dev/documentation/meta/latest/meta/UseResult-class.html
[meta-visibleForOverriding]: https://pub.dev/documentation/meta/latest/meta/visibleForOverriding-constant.html
[meta-visibleForTesting]: https://pub.dev/documentation/meta/latest/meta/visibleForTesting-constant.html
"

@data = {
'title' => name,
'layout' => 'default'
}

end
end
end
7 changes: 7 additions & 0 deletions src/_plugins/name_breaker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module NameBreaker
def name_breaker(breaking_string)
return breaking_string.gsub('_', '_<wbr />')
end
end

Liquid::Template.register_filter(NameBreaker)
21 changes: 21 additions & 0 deletions src/assets/js/single_to_multiple_redirector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function setupRedirects(oldPage, newDirectory) {
const oldFragment = window.location.hash;
if (!oldFragment || oldFragment.length === 0) {
window.location = newDirectory;
return;
}

const newDestination = newDirectory + oldFragment.substring(1);

fetch(newDestination)
.then((response) => {
if (response.status === 200) {
window.location = newDestination;
}
});
}

const currentLocation = window.location.href;
if (currentLocation.includes('diagnostic-messages')) {
setupRedirects('', window.location.origin + '/tools/diagnostics/');
}