Patch 1: makefile + fixes #467
Patch 1: makefile + fixes #467
Conversation
Instead of relying on timestamped dummy files to track dependencies, we create a list of separate targets to build from their corresponding sources. This is a better design because it allows recompiling only the modified targets instead of all or nothing. However the timestamp approach was kept for the lang-aliases rule because the alias targets are not known in advance and have to be extracted out of the language handler scripts. The code to extract lang-alias was ported to a node.js script, instead of the existing solution based on bash + perl + js-interpreter. The compiled files are placed directly into the "loader" folder, and and old cruft is dropped (no need for multiple archive formats TAR/TGZ/BZ2), instead only one ZIP archive is generated in the "distrib" folder.
C99: restrict C++11: alignas, noexcept, noreturn C_TYPES (STL containers): array, forward_*, reverse_*, unordered_*
include('defs.js') in prettify.js was inserted in the wrong place, this is because of the way the perl script expects surrounding lines to look like. So we add a dummy variable declaration without preceding comment lines.
* Widely used with good cross-browser support. Powers https://code.google.com/ | ||
and http://stackoverflow.com/ | ||
|
||
[See an example][2]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually lifted that features list from the old wiki pages :)
https://github.com/google/code-prettify/blob/wiki/ProjectHome.md
| callback=js_ident | | `window.exports["js_ident"]` will be called when prettyprinting finishes. If specified multiple times, all are called. | | ||
| CGI parameter | default | meaning | | ||
| --------------------- | ------- | ------------------------------ | | ||
| autorun=(true, false) | true | run automatically on page load | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
"internal,into,is,let,lock,null,object,out,override,orderby,params," + | ||
"partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong," + | ||
"unchecked,unsafe,ushort,var,virtual,where"]; | ||
"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending," + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take your word for it. C#'s keyword list is approaching the union of all other language's keywords.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1662,7 +1665,7 @@ var IN_GLOBAL_SCOPE = false; | |||
'keywords': JSCRIPT_KEYWORDS, | |||
'cStyleComments': true, | |||
'regexLiterals': true | |||
}), ['javascript', 'js']); | |||
}), ['javascript', 'js', 'ts', 'typescript']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: we can think about .jsx
down the road.
(Apparently Facebook reinvented E4X and is calling it React JS.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thing, this is coming from an already merged PR #423, which modified the generated file src/prettify.js
and not the actual source in js-modules/prettify.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(JSX style of mixing JS/XML syntax would be a nice addition)
@@ -0,0 +1,87 @@ | |||
#!/usr/bin/env node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: port of https://github.com/google/code-prettify/blob/master/tools/lang-handler-aliases.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep. I should mention that I rewrote this script again, in a later patch, as a grunt plugin..
|
||
// for each unique alias, copy file if not already exist | ||
langExtensions.filter(function (ext, pos) { | ||
return langExtensions.indexOf(ext) == pos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: equivalent of | uniq.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, I think I borrowed it from here: http://stackoverflow.com/a/14438954/97160
We could shorten some of this stuff by using a library like underscore or lodash, but I wanted to avoid adding npm dependencies if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on minimal dependencies
}); | ||
|
||
// collect extensions list | ||
var langExtensions = sandbox.langExtensions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you sort the extensions here?
I should have in the original script to remove file-system child ordering as a source of non-determinism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will add .sort()
@@ -49,7 +49,7 @@ | |||
* +------------------+---------------+------------------------------+--------+ | |||
* | |||
* Exmaples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not your fault but s/Exmaples/Examples/ please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[ \n\r\t\v\f\0]+/,null," \n\r\t\v\f\x00"],["str",/^"(?:[^"\\]|(?:\\.)|(?:\\\((?:[^"\\)]|\\.)*\)))*"/,null,'"']],[["lit",/^(?:(?:0x[\da-fA-F][\da-fA-F_]*\.[\da-fA-F][\da-fA-F_]*[pP]?)|(?:\d[\d_]*\.\d[\d_]*[eE]?))[+-]?\d[\d_]*/,null],["lit",/^-?(?:(?:0(?:(?:b[01][01_]*)|(?:o[0-7][0-7_]*)|(?:x[\da-fA-F][\da-fA-F_]*)))|(?:\d[\d_]*))/,null],["lit",/^(?:true|false|nil)\b/,null],["kwd",/^\b(?:__COLUMN__|__FILE__|__FUNCTION__|__LINE__|#available|#else|#elseif|#endif|#if|#line|arch|arm|arm64|associativity|as|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|dynamicType|else|enum|fallthrough|final|for|func|get|import|indirect|infix|init|inout|internal|i386|if|in|iOS|iOSApplicationExtension|is|lazy|left|let|mutating|none|nonmutating|operator|optional|OSX|OSXApplicationExtension|override|postfix|precedence|prefix|private|protocol|Protocol|public|required|rethrows|return|right|safe|self|set|static|struct|subscript|super|switch|throw|try|Type|typealias|unowned|unsafe|var|weak|watchOS|while|willSet|x86_64)\b/, | ||
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[ \n\r\t\v\f\0]+/,null," \n\r\t\v\f\x00"],["str",/^"(?:[^"\\]|(?:\\.)|(?:\\\((?:[^"\\)]|\\.)*\)))*"/,null,'"']],[["lit",/^(?:(?:0x[\da-fA-F][\da-fA-F_]*\.[\da-fA-F][\da-fA-F_]*[pP]?)|(?:\d[\d_]*\.\d[\d_]*[eE]?))[+-]?\d[\d_]*/,null],["lit",/^-?(?:(?:0(?:(?:b[01][01_]*)|(?:o[0-7][0-7_]*)|(?:x[\da-fA-F][\da-fA-F_]*)))|(?:\d[\d_]*))/,null],["lit",/^(?:true|false|nil)\b/,null],["kwd",/^\b(?:__COLUMN__|__FILE__|__FUNCTION__|__LINE__|#available|#else|#elseif|#endif|#if|#line|arch|arm|arm64|associativity|as|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|dynamicType|else|enum|extension|fallthrough|final|for|func|get|guard|import|indirect|infix|init|inout|internal|i386|if|in|iOS|iOSApplicationExtension|is|lazy|left|let|mutating|none|nonmutating|operator|optional|OSX|OSXApplicationExtension|override|postfix|precedence|prefix|private|protocol|Protocol|public|required|rethrows|return|right|safe|self|set|static|struct|subscript|super|switch|throw|try|Type|typealias|unowned|unsafe|var|weak|watchOS|while|willSet|x86_64)\b/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: adds "extension" and "guard"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is coming from PR #415
@@ -59,6 +59,8 @@ | |||
|
|||
include("defs.js"); | |||
|
|||
var HACK_TO_FIX_JS_INCLUDE_PL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required by your port of jsinclude.pl? In another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, I got rid of it later, along with the perl scripts and the entire makefile.
(some of these fixes were made before I started working on porting to a grunt solution)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks harmless and no need to create merge work for the patch PR.
The thing is files under oops, accidentally closed PR. |
summary:
HACK_TO_FIX_JS_INCLUDE_PL
injs-modules/prettify.js
as a hack so that the lineinclude('defs.js')
is correctly handledjs-modules/prettify.js
which were only modifying the generatedsrc/prettify.js
I also ran
make
and committed the generated files (in preparation for a last release using makefile before we switch to grunt).