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

Node annotations in DocumentationBrowser #11153

Merged
merged 41 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
561b029
add packageDocManager to handle package documentation links
SHKnudsen Sep 17, 2020
4257141
new viewModelEventArgs to send node annotation data to doc browser
SHKnudsen Sep 17, 2020
1d50fab
Handle node annotation in doc browser
SHKnudsen Sep 17, 2020
df7c944
support custom NodeModels + fix watcher event bug
SHKnudsen Sep 21, 2020
0966ef6
Update NodeAnnotationNotFound.md
radumg Sep 21, 2020
afb9636
Update NodeAnnotationNotFound.md
radumg Sep 21, 2020
1372265
Comment updates
SHKnudsen Sep 22, 2020
3897991
Update AssemblySharedInfo.cs
SHKnudsen Sep 22, 2020
ff33549
Update src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelEventArgs.cs
radumg Sep 22, 2020
03f123c
addtional comment updates + clean up
SHKnudsen Sep 22, 2020
acfdaa1
Merge branch 'Node-annotations-doc-browser' of https://github.com/SHK…
SHKnudsen Sep 22, 2020
64793a9
clean up packageDocManager
SHKnudsen Sep 22, 2020
0b81edb
Update DocumentationBrowserViewModel.cs
SHKnudsen Sep 22, 2020
ba89de9
Merge branch 'master' into Node-annotations-doc-browser
SHKnudsen Sep 25, 2020
798e777
handle overloads + fix hot reload bug
SHKnudsen Sep 29, 2020
658ef26
use HtmlSanitizer to clean potential dangerous content from markdown …
SHKnudsen Sep 30, 2020
3298bb6
move PackageDocumentationManager to DocumentationBrowser
SHKnudsen Sep 30, 2020
ad4ce3a
update syntax highlighting + markdownStyling updates
SHKnudsen Oct 1, 2020
df8e1e2
comment updates
SHKnudsen Oct 6, 2020
5f270b5
add Markdig to License files
SHKnudsen Oct 6, 2020
214ff10
Change GetPackageName to GetMainCategory
SHKnudsen Oct 7, 2020
021123a
update markdig + htmlsanitizer version
SHKnudsen Oct 8, 2020
174b8c0
Merge branch 'master' into Node-annotations-doc-browser
SHKnudsen Oct 22, 2020
7790fc1
fix failing tests + add new node documentaion tests
SHKnudsen Oct 23, 2020
9ab1016
Merge branch 'master' into Node-annotations-doc-browser
SHKnudsen Nov 11, 2020
d18269f
fix broken test
SHKnudsen Nov 11, 2020
1001be3
update link to wiki
SHKnudsen Nov 12, 2020
d5a84fc
Update DocumentationBrowserViewExtension.cs
SHKnudsen Nov 12, 2020
71509da
Add MD2HTML Tool
sm6srw Nov 17, 2020
bbefc36
First pass - singleton version
sm6srw Nov 17, 2020
99b42f2
Revert "Add MD2HTML Tool"
sm6srw Nov 17, 2020
f655c39
Revert "First pass - singleton version"
sm6srw Nov 17, 2020
7862382
fix test
SHKnudsen Nov 19, 2020
3ce2cc0
add doc folder to PackageDirectoryBuilder (#10)
SHKnudsen Nov 20, 2020
c8cf9f3
Use a CLI tool for converting MD to HTML and for Sanitizing HTML as a…
sm6srw Nov 23, 2020
389d6c0
Merge master (#12)
sm6srw Nov 23, 2020
b29876e
Merge branch 'master' into Node-annotations-doc-browser
mjkkirschner Nov 23, 2020
8a63d91
Extract more strings (#13)
sm6srw Nov 23, 2020
df7a483
Fix failing tests (#14)
sm6srw Nov 24, 2020
eac0196
More failing test fixes (#15)
sm6srw Dec 2, 2020
a7c7303
Merge branch 'master' into Node-annotations-doc-browser
mjkkirschner Dec 2, 2020
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
250 changes: 250 additions & 0 deletions src/DocumentationBrowserViewExtension/Docs/MarkdownStyling.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
<!-- These headers are required to force the browser embedded in the DocumentationBrowser extension to render in modern IE11 mode. -->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
/* PrismJS 1.21.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this css extracted from prisim.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript+bash+c+csharp+cpp+ini+java+javadoc+javadoclike+javastacktrace+json+json5+jsonp+jsstacktrace+js-templates+markdown+powershell+python+sql+typescript+typoscript+xml-doc */
/**
* prism.js tomorrow night eighties for JavaScript, CoffeeScript, CSS and HTML
* Based on https://github.com/chriskempson/tomorrow-theme
* @author Rose Pritchard
*/
code[class*=language-], pre[class*=language-] {
color: #ccc;
background: 0 0;
font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none
}

pre[class*=language-] {
padding: 1em;
margin: .5em 0;
overflow: auto
}

:not(pre) > code[class*=language-], pre[class*=language-] {
background: #1e1e1e
}

:not(pre) > code[class*=language-] {
padding: .1em;
border-radius: .3em;
white-space: normal
}

.token.block-comment, .token.cdata, .token.comment, .token.doctype, .token.prolog {
color: #999
}

.token.punctuation {
color: #ccc
}

.token.attr-name, .token.deleted, .token.namespace, .token.tag {
color: #e2777a
}

.token.function-name {
color: #6196cc
}

.token.boolean, .token.function, .token.number {
color: #f08d49
}

.token.class-name, .token.constant, .token.property, .token.symbol {
color: #f8c555
}

.token.atrule, .token.builtin, .token.important, .token.keyword, .token.selector {
color: #cc99cd
}

.token.attr-value, .token.char, .token.regex, .token.string, .token.variable {
color: #7ec699
}

.token.entity, .token.operator, .token.url {
color: #67cdcc
}

.token.bold, .token.important {
font-weight: 700
}

.token.italic {
font-style: italic
}

.token.entity {
cursor: help
}

.token.inserted {
color: green
}
</style>
<style>
h1{
margin-top:0;
}

body {
color: #fff;
font-size: 14px;
font-family: "Artifakt Element";
src: url(fonts/ArtifaktElement-Regular.woff) format("woff");
padding: 1%;
background-color: #353535;
font-family: 'Artifakt Element','Open Sans'
}

a {
color: #d3d3d3;
cursor: pointer;
background-color: transparent
}

table {
border-collapse: collapse;
border: 1px solid #fff
}

td, th {
border: 1px solid #fff;
padding-right: 10px;
padding-left: 10px;
padding-bottom: 10px;
padding-top: 10px
}

samp {
margin-top: 10px;
display: block;
color: #d3d3d3
}

thead {
text-align: center
}

.hidden-lg {
display: none
}

.table--noborder {
border: none
}

.table--noborder td, .table--noborder th {
border: none
}

img {
width: 100%;
height: auto
}

code,
pre {
color: #ccc;
background: 0 0;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
background: #1e1e1e !important;
}

pre {
padding: 1em;
margin: .5em 0;
overflow: auto
}

:not(pre) > code {
background: #1e1e1e;
padding: .1em;
border-radius: .3em;
white-space: normal;
}

@media screen and (max-width:600px) {
table {
width: 100%
}

table, td, th {
border: none
}

tr {
border: 1px solid #fff;
display: block
}

td, th {
display: block
}

.hidden-lg {
display: block;
font-weight: 700;
text-align: center;
border-bottom: 1px solid #fff
}

.hidden-sm {
display: none
}

.spaced-sm {
margin-top: 20px
}

tbody tr:first-of-type {
border-bottom: none
}

.button {
background-color: transparent;
border-color: #3c3c3c;
color: #bbb
}

.button:hover {
border-color: #656565;
background-color: #373737;
opacity: 1
}
}
</style>
</head>


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## No further documentation provided for this node.

For more information on how to add extended documentation to your custom nodes, have a look [here](https://github.com/DynamoDS/Dynamo/wiki).
radumg marked this conversation as resolved.
Show resolved Hide resolved
30 changes: 30 additions & 0 deletions src/DocumentationBrowserViewExtension/Docs/syntaxHighlight.html

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions src/DocumentationBrowserViewExtension/DocumentationBrowserUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using Ganss.XSS;

namespace Dynamo.DocumentationBrowser
{
/// <summary>
/// Common utilities used across classes in the DocumentationBrowserViewExtension.
/// </summary>
internal static class DocumentationBrowserUtils
{
private const string DPISCRIPT = @"<script>
function getDPIScale()
{
var dpi = 96.0;
if (window.screen.deviceXDPI != undefined)
{
dpi = window.screen.deviceXDPI;
}
else
{
var tmpNode = document.createElement('DIV');
tmpNode.style.cssText = 'width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden';
document.body.appendChild(tmpNode);
dpi = parseInt(tmpNode.offsetWidth);
tmpNode.parentNode.removeChild(tmpNode);
}

return dpi / 96.0;
}

function adaptDPI()
{
var dpiScale = getDPIScale();
document.body.style.zoom = dpiScale;

var widthPercentage = ((100.0 / dpiScale)-5).toString() + '%';
document.body.style.width = widthPercentage;
}
adaptDPI()
</script>";
private static HtmlSanitizer htmlSanitizer = new HtmlSanitizer();

/// <summary>
/// Clean up possible dangerous HTML content from the content string.
/// </summary>
/// <param name="content"></param>
/// <returns>Returns true if any content was removed from the content string</returns>
internal static bool RemoveScriptTagsFromString(ref string content)
{
var sanitizedContent = htmlSanitizer.Sanitize(content);
if (content.Equals(sanitizedContent))
return false;

content = sanitizedContent;
return true;
}

/// <summary>
/// Returns the DPIScript
/// </summary>
/// <param name="content"></param>
internal static string GetDPIScript()
{
return DPISCRIPT;
}

/// <summary>
/// Returns the content of an embedded resource file.
/// </summary>
/// <param name="resourceName"></param>
/// <returns></returns>
internal static string GetContentFromEmbeddedResource(string resourceName)
{
var assembly = Assembly.GetExecutingAssembly();
var result = "";

using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
{
result = reader.ReadToEnd();
}

return result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public DocumentationBrowserView(DocumentationBrowserViewModel viewModel)
// so we know when to navigate to a new documentation page/document
viewModel.LinkChanged += NavigateToPage;

viewModel.ContentChanged += OnContentChanged;

// handle browser component events & disable certain features that are not needed
this.documentationBrowser.AllowDrop = false;
this.documentationBrowser.Navigating += ShouldAllowNavigation;
Expand Down Expand Up @@ -88,13 +90,17 @@ private void ShouldAllowNavigation(object sender, NavigatingCancelEventArgs e)
/// <param name="link"></param>
public void NavigateToPage(Uri link)
{
this.documentationBrowser.NavigateToString(this.viewModel.GetContent());
Dispatcher.BeginInvoke(new Action(() =>
{
this.documentationBrowser.NavigateToString(this.viewModel.GetContent());
}));
}

protected virtual void Dispose(bool disposing)
{
// Cleanup
this.viewModel.LinkChanged -= NavigateToPage;
this.viewModel.ContentChanged -= OnContentChanged;
this.documentationBrowser.Navigating -= ShouldAllowNavigation;
this.documentationBrowser.Dispose();
this.documentationBrowser.DpiChanged -= DocumentationBrowser_DpiChanged;
Expand Down
Loading