TypeDoc how to define externalPattern? - regex

I'm working on app with grunt and typedoc.
I need to prepare documentation using TypeDoc but I have a problem with one scenario.
I have to exclude a few files from documentation which are externals libs.
I can't put those files into exclude section because those files are relating with another. If I tried to exclude it (by put those files into exclude section) I had a errors - something like cannot find to xxx into yyy.ts - where xxx is my excluded element and yyy is related file with xxx. Those
related files are neccessary on this documentation so I can't exclude those too.
I read into TypeDoc documentation about excludeExternals. So I thought that if I set up this boolean as true then I can to define externalPattern to exclude my external files. It's works but only if I put the name of one file - no more.
Do You know how to do it?
It is my typedoc config into gruntfile.js (without excludeExternals options):
typedoc: {
build: {
options: {
module: 'commonjs',
out: '../Documentation/',
name: 'MyApp',
target: 'es5',
exclude: [
'node_modules',
'**/*.d.ts'
],
excludePrivate: true,
mode: 'file'
},
src: [
...some source...
]
}
}
This is list of external files which I have to exclude: A.ts, B.ts, C.ts, D.ts ...
And this is my typedoc config into gruntfile.js (with excludeExternals options):
typedoc: {
build: {
options: {
module: 'commonjs',
out: '../Documentation/',
name: 'MyApp',
target: 'es5',
exclude: [
'node_modules',
'**/*.d.ts'
],
excludeExternals: true,
externalPattern: '**/*/A.ts',
excludePrivate: true,
mode: 'file'
},
src: [
...some source...
]
}
}
This config is working well. I have got a documentation without A.ts file. So now I need to put a few files, so I tried to put on externalPattern something like: **/*/(A|B|C|D).ts but without success (because during recompiling of documentation I had error: Process terminated with code 3. 'B' is not recognized as an internal or external command, operable program or batch file.).
Any ideas?

I found the solution. If I want to exclude externals files using externalPattern I should to write pattern something like that:
externalPattern: "**/*/{A,B,C,D}.ts"
{ } = allows for a comma-separated list of "or" expressions
, = or
Useful for me was this comment from topic about regex in gruntfile.

According to this comment, the right syntax would be **/*/+(A|B|C|D).ts. Also, it looks like you are running into a problem with your shell trying to interpret the pipe characters, so try adding double quotes around the whole thing:
externalPattern: '"**/*/+(A|B|C|D).ts"'

Related

SourceMap read failed

I have a WinJS-UWP-Application, where I use TypeScript 2.5. I just upgraded from VS2015 to VS2017. When I want to debug my WinJS-UWP-Application the Breakpoints inside my .ts-Files are not noted, because the SourceMap isnt read properly. I didn't change any configuration of the project.
In the output I get this message:
SourceMap
ms-appx://8d7814f6-7286-4475-8ed8-be1c489c2253/js/main.js.map read
failed: The URI prefix is not recognized..
My CompilerOptions are:
"compilerOptions": {
"target": "es5",
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true
}
The min and target version of the application are: 10.0.14393.0
Do I need to setup anything else in VS2017?
EDIT:
Steps to reproduce:
Create a new UWP WinJS-App in VS 17 with Min and Target Version: 10.0.14393.0
Remove the js\main.js
Add a main.ts file in the js folder
Create a tslib folder and insert the winjs.d.ts inside [For example from DefinetlyTyped]
Add the following code inside the main.ts:
/// <reference path="../tslib/winjs.d.ts"/>
WinJS.UI.processAll().then(() => {
let div: HTMLDivElement = document.createElement("div");
let label: HTMLLabelElement = document.createElement("label");
label.textContent = "Hello from the TypeScript-Side";
div.appendChild(label);
document.body.appendChild(div);
});
Add a new tsconfig.json from the VS17 template.
Start the app with the AnyCPU Configuration
Expected result:
Inside the App you see the text:
Content goes here!
Hello from the TypeScript-Side
In the ouput you see these two messages:
'WWAHost.exe' (Script): Loaded 'Script Code (MSAppHost/3.0)'.
SourceMap ms-appx://32fb2864-03cf-4387-8a05-6c65a66c5a48/js/main.js.map read failed: The URI prefix is not recognized..
EDIT 2:
The content of the main.js.map:
{
"version": 3,
"file": "main.js",
"sourceRoot": "",
"sources": [ "main.ts" ],
"names": [],
"mappings": "AAAA,2CAA2C;AAE3C,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC;IACvB,IAAI,GAAG,GAAmB,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACxD,IAAI,KAAK,GAAqB,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9D,KAAK,CAAC,WAAW,GAAG,gCAAgC,CAAC;IACrD,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC"
}
EDIT3:
TypescriptBuild-Settings:
TypeScript version: 2.5
Compile on save: Yes
Allow implicit 'any' types: Yes
Keep comments in JavaScript output: Yes
Generate declaration files: No
Generate source maps: Yes
Specify root directory of source maps: $(MSBuildProjectDirectory)
Specify root directory of TypeScript files: $(MSBuildProjectDirectory)
Emit on error: No
If I delete the tsconfig.json, the source maps are created correctly. But i need the tsconfig.json for a few other options, so deleting it is not an option!
I found a workaround which fixes the problem for the moment. I don't know why this works, but if you add the line:
"mapRoot": "js/"
it works correctly.
This only works for the default directory setup!

Codeception\Test\Unit not found

I am having some problems with Codeception using Yii2. I just upgraded to Yii 2.0.10 and have been using this guide
I am getting the error: Codeception\Test\Unit not found in vendor\codeception\base\shim.php. If I ocmment this class out, the next one fails which is:
namespace Codeception\Module {
class Symfony2 extends Symfony {
}
This is what've done: I created a file test.php and put it in my config folder:
<?php
// config/test.php
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/main.php'),
require(__DIR__ . '/main-local.php'),
[
'id' => 'app-tests',
'components' => [
'db1' => require(__DIR__ . '/db.php'),
]
]
);
return $config;
codeception.yaml
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
memory_limit: 1024M
colors: true
modules:
config:
Yii2:
configFile: 'config/test.php'
unit.suite.yml
class_name: UnitTester
modules:
enabled:
- Asserts
- Yii2:
part: [orm, email]
I'm completely new to Codeception, so not sure what I've done wrong
As far as I remember you have to do nothing except php vendor/bin/codecept run in directory where you have codeception.yaml.
Please note that path vendor/bin/codecept may differ in your case. Generally speaking Codeception will parse your configuration and do the magic.
It's not necessary to know but if you're interested: it parses configuration and establishes relations between namespaces and paths dynamically by using its own PSR-4 compatible class autoloader implementation.
Take a look here - https://github.com/Codeception/Codeception/blob/2.2/src/Codeception/Configuration.php#L214 and here https://github.com/Codeception/Codeception/blob/2.2/src/Codeception/Util/Autoload.php
In this situation as I upgraded from 2.0.9 -> 2.0.10. I had to composer remove yiisoft/yii2-codeception, codeception/codeception, codeception\verify, codeception\specify, codeception\base.
I copied the test folder structure over. Changed my composer.json in the root project to include:
"require-dev": {
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*",
"codeception/base": "^2.2.3",
"codeception/verify": "~0.3.1",
"codeception/specify": "~0.4.3"
},
I also added the test.php and test_db.php files to /config

Babel ignore equivalent in ember engines?

In a traditional Ember app, I have something along the lines of this in my ember-cli-build.js:
//ember-cli-build.js
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
babel: {
includePolyfill: true,
ignore: ['my-ember-ui/models/myFile.js'] // <-- question is here
},
Is there an equivalent to this when using an Ember Engine (or addon)? I couldn't find anything within ember-cli-babel or ember-engines.
I understand that ember-cli-build.js is just for the dummy app when using an engine, so I wouldn't make the change there. I attempted similar to above in the index.js file, but did not have any luck. The file was not ignored by babel. I need a way to ignore a particular file. Thanks!
Well, adding new rules to Cli.build.js is ok depends on what you want to do. However, I may have another solution that you can give it a try.
Babel will look for a .babelrc in the current directory of the file being transpiled. If one does not exist, it will travel up the directory tree until it finds either a .babelrc, or a package.json with a "babel": {} hash within.(.babelrc files are serializable JSON).
{
"plugins": ["transform-react-jsx"],
"ignore": [
"foo.js",
"bar/**/*.js"
]
}
or
{
"name": "my-package",
"version": "1.0.0",
"babel": {
// my babel config here
}
}
There should be another way which seems ok to use. the following does work:
babel src --out-dir build --ignore "**/*.test.js" // or simply add your file
For more information, you can read Babel document

How to select all files, but exclude particular file extensions in a directory

I wanted to copy all files in a folder, but I wanted to exclude a particular file-extension in a sub-folder. How can I do that?
Here's a snippet of my code:
frontendDev: {
files: [{
expand: true,
cwd: './frontend/app',
src: ['!angular/*.js', '**/*.!(coffee|less|scss|sass)'],
dest: './frontend/.dev'
}]
},
Note: Here I wanted to copy all the files, but I wanted to exclude the (.js) files in the angular sub-folder.
Any thoughts? Thanks
UPDATE - ANSWER
Base on what Raptis Dimos said Inclusion and Exclusion order is important.
So I put the inclusion first then last is the exclusion.
frontendDev: {
files: [{
expand: true,
cwd: './frontend/app',
src: ['**/*.!(coffee|less|scss|sass)', '!angular/**/*.js'],
dest: './frontend/.dev'
}]
},
This is how it works. The ! in Grunt turns the expression into an "exclude" expression.
You can also check the Grunt docs, saying :
Paths matching patterns that begin with ! will be excluded from the returned array. Patterns are processed in order, so inclusion and exclusion order is significant.

Build layer that doesn't contain dojo/**/*.js files

I am attempting to create a layer for my project. I would like the layer to contain
myProject/controllers/MainApp and all of its dependencies that are in the myProject
package. I do not want to include any dojo, dijit or otherPackages in my layer.
This is what I have so far:
var profile = (function() {    
var locationPrefix = "something";
return {        
basePath: "../src",
        releaseDir: "../dojoRelease",
        releaseName: "lib",
        action: "release",
packages: [
{
name: 'dojo',
location: locationPrefix + '/dojo/dojo'
}, {
name: 'dijit',
location: locationPrefix + '/dojo/dijit'
}, {
...
}, {
name: 'myProject',
location: 'myProject',
destLocation: 'myProject'
}
],
layers: {          
"myProject": {
include: ["myProject/controllers/MainApp"],
// QUESTION: How can I use exclude to not include all dojo modules?
// tried several things but none seem to work. Can't find any doc
// on what exclude takes as input.
// exclude: ["dojo/dojo"],
boot: false,
customBase: true
}
}    
};
})();
The problem is that when I look at my main.js.uncompressed.js it contins lots of things that are not
in myProject. These are the first few lines in the main.js.uncompressed.js file:
require({cache:{
'dojo/parser':function(){
define([
"require", "./_base/kernel", "./_base/lang", "./_base/array", "./_base/config", "./dom", "./_base/window",
"./_base/url", "./aspect", "./promise/all", "./date/stamp", "./Deferred", "./has", "./query", "./on", "./ready"
], function(require, dojo, dlang, darray, config, dom, dwindow, _Url, aspect, all, dates, Deferred, has, query, don, ready){
// module:
// dojo/parser
new Date("X"); // workaround for #11279, new Date("") == NaN
// data-dojo-props etc. is not restricted to JSON, it can be any javascript
function myEval(text){
return eval("(" + text + ")");
}
The source for:
dijit/_Widget
dojo/Stateful
dijit/Destroyable
dijit/_OnDijitClickMixin
dijit/a11yclick
and many other files also show up in the main.js.uncompressed.js file.
How can I limit the main.js.uncompressed.js file to be only the files
in my project? Thanks!
Update: I tried removing dojo, dijit, etc from the list of packages. This causes the main.js.uncompressed.js to generate more or less correctly, the compiler then hangs on generating the minified file. There are also many errors like this:
error(311) Missing dependency. module: myProject/controllers/someFile; dependency: dojo/_base/declare
error(311) Missing dependency. module: myProject/controllers/someFile; dependency: dojo/_base/lang
error(311) Missing dependency. module: myProject/controllers/someFile; dependency: dojo/Deferred
The problem is that when I look at my main.js.uncompressed.js it
contins lots of things that are not in myProject.
They might not be in myProject but are you sure you're not making use of any of them anywhere? For example in the output you include it shows that someFile is using dojo/_base/declare function. If you're using declare at the start of your someFile module then you'll need dojo in the layer to be able to run it.
error(311) Missing dependency. module: myProject/controllers/someFile; dependency: dojo/_base/declare
error(311) Missing dependency. module: myProject/controllers/someFile; dependency: dojo/_base/lang
error(311) Missing dependency. module: myProject/controllers/someFile; dependency: dojo/Deferred
Can't find any doc on what exclude takes as input.
It's the same format as the include - an array of string modules - see here:
http://dojotoolkit.org/documentation/tutorials/1.10/build/
http://dojotoolkit.org/reference-guide/1.10/build/
Using the boot property will also included some dojo code in your layer as you're telling the builder to make your layer bootable so it has to include the dojo code for module loading to let you load youre other modules.