Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dgeni-packages

Package Overview
Dependencies
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dgeni-packages - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

16

examples/processors/examples-generate.js

@@ -14,3 +14,3 @@ var _ = require('lodash');

function createExampleDoc(example, deployment, stylesheets, scripts) {
var deploymentQualifier = deployment.name === 'default' ? '' : '-' + deployment.name;
var deploymentQualifier = deployment.name === 'default' ? '' : ('-' + deployment.name);
var commonFiles = (deployment.examples && deployment.examples.commonFiles) || {};

@@ -48,8 +48,7 @@ var dependencyPath = deployment.examples.dependencyPath || '.';

// If there is an index.html file specified then use it contents for this doc
// and remove it from the files property
if ( example.files['index.html'] ) {
exampleDoc.fileContents = example.files['index.html'].fileContents;
delete example.files['index.html'];
// If there is content specified for the index.html file then use its contents for this doc
if ( example.indexFile ) {
exampleDoc.fileContents = example.indexFile.fileContents;
}
return exampleDoc;

@@ -95,4 +94,9 @@ }

// We don't want to create a file for index.html, since that will be covered by the exampleDoc
example.indexFile = example.files['index.html'];
delete example.files['index.html'];
// Create a new document for each file of the example
_.forEach(example.files, function(file) {
var fileDoc = createFileDoc(example, file);

@@ -99,0 +103,0 @@ docs.push(fileDoc);

var plugin = require('../../processors/examples-generate');
var configurer = require('dgeni/lib/utils/config');
var _ = require('lodash');
describe("examples-generate processor", function() {
var docs, examples;
beforeEach(function() {
var config = configurer.load();
config.set('processing.examples.templateFolder', 'examples');
config.set('deployment.environments', {
default: {
config.set('deployment.environments', [
{
name: 'default',
examples: {

@@ -17,3 +19,4 @@ commonFiles: [],

other: {
{
name: 'other',
examples: {

@@ -26,8 +29,10 @@ commonFiles: {

}
});
]);
plugin.init(config, { value: function() { }});
});
it("should add new documents that represent the examples", function() {
var docs = [ { file: 'a.b.js' }];
var examples = [
docs = [
{ file: 'a.b.js' }
];
examples = [
{

@@ -38,7 +43,8 @@ id: 'a.b.c',

deps: 'dep1.js;dep2.js',
files: [
{ type: 'js', name: 'app.js' },
{ type: 'css', name: 'app.css' },
{ type: 'spec', name: 'app.spec.js' }
]
files: {
'index.html': { type: 'html', name: 'index.html', fileContents: 'index.html content' },
'app.js': { type: 'js', name: 'app.js', fileContents: 'app.js content' },
'app.css': { type: 'css', name: 'app.css', fileContents: 'app.css content' },
'app.spec.js': { type: 'spec', name: 'app.spec.js', fileContents: 'app.spec.js content' }
}
}

@@ -49,16 +55,32 @@ ];

expect(docs[1]).toEqual(
});
it("should add an exampleDoc for each example deployment", function() {
var exampleDocs = _.filter(docs, { docType: 'example' });
expect(exampleDocs.length).toBe(2);
expect(exampleDocs[0]).toEqual(
jasmine.objectContaining({ docType: 'example', id:'a.b.c', template: 'examples/index.template.html'})
);
expect(exampleDocs[1]).toEqual(
jasmine.objectContaining({ docType: 'example', id:'a.b.c-other', template: 'examples/index.template.html'})
);
expect(exampleDocs[0].fileContents).toEqual('index.html content');
expect(exampleDocs[1].fileContents).toEqual('index.html content');
});
it("should add a fileDoc for each of the example's files", function() {
expect(_.find(docs, { id: 'a.b.c/app.js' })).toEqual(
jasmine.objectContaining({ docType: 'example-js', template: 'examples/template.js' })
);
expect(docs[2]).toEqual(
expect(_.find(docs, { id: 'a.b.c/app.css' })).toEqual(
jasmine.objectContaining({ docType: 'example-css', template: 'examples/template.css' })
);
expect(docs[3]).toEqual(
expect(_.find(docs, { id: 'a.b.c/app.spec.js' })).toEqual(
jasmine.objectContaining({ docType: 'example-spec', template: 'examples/template.spec' })
);
expect(docs[4]).toEqual(
jasmine.objectContaining({ docType: 'example', template: 'examples/index.template.html' })
);
});
expect(docs[4].scripts).toEqual([
it("should add the dependencies to the exampleDoc scripts", function() {
expect(_.find(docs, { id: 'a.b.c' }).scripts).toEqual([
{ path : 'dep1.js' },

@@ -69,3 +91,3 @@ { path : 'dep2.js' },

expect(docs[5].scripts).toEqual([
expect(_.find(docs, { id: 'a.b.c-other' }).scripts).toEqual([
{ path: 'someFile.js' },

@@ -72,0 +94,0 @@ { path: 'someOtherFile.js' },

@@ -102,2 +102,14 @@ var _ = require('lodash');

it("should extract the container and member from the name if it is a memberOf type", function() {
doc.docType = 'method';
doc.name = '$http#get';
doc.area = 'api';
doc.module = 'ng';
expect(tagDef.defaultFn(doc)).toEqual('$http#get');
expect(doc.name).toEqual('get');
expect(doc.memberof).toEqual('$http');
expect(doc.isMember).toEqual(true);
});
});

@@ -104,0 +116,0 @@ });

@@ -57,3 +57,3 @@ var checkProperty = require('dgeni/lib/utils/check-property');

defaultFn: function(doc) {
var partialFolder = 'partials';
var parts, partialFolder = 'partials';
if ( doc.area === 'api' && doc.docType !== 'overview' ) {

@@ -73,3 +73,5 @@ if ( doc.docType === 'module' ) {

doc.isMember = true;
doc.memberof = doc.id.split('#')[0];
parts = doc.id.split('#');
doc.memberof = parts[0];
doc.name = parts[1];
// This is a member of another doc so it doesn't need an output path

@@ -83,3 +85,3 @@ }

doc.id = doc.name;
var parts = doc.id.split(':');
parts = doc.id.split(':');
doc.namespace = parts[0];

@@ -86,0 +88,0 @@ doc.name = parts[1];

{
"name": "dgeni-packages",
"version": "0.2.1",
"version": "0.2.2",
"description": "A collection of dgeni packages for generating documentation from source code",

@@ -5,0 +5,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc