Skip to content

Instantly share code, notes, and snippets.

@adriancmiranda
Last active September 25, 2016 03:28
Show Gist options
  • Select an option

  • Save adriancmiranda/d9096dc8953628172ae73735a5667d06 to your computer and use it in GitHub Desktop.

Select an option

Save adriancmiranda/d9096dc8953628172ae73735a5667d06 to your computer and use it in GitHub Desktop.
python scratch parser sample
import path from 'path';
import webpack from 'webpack';
import queryString from 'querystring';
const root = path.resolve(__dirname);
const sourcePathDir = path.join(root, 'source');
/**
* webpack
* @description The webpack factory method.
* @see http://webpack.github.io/docs/configuration.html#configuration-object-content
*/
export webpack;
/**
* context
* @description
* @see http://webpack.github.io/docs/configuration.html#context
*/
export class WebpackContext {
constructor(opts = {}) {
}
parse() {
}
}
/**
* entry
* @description The entry point for the bundle.
* @see http://webpack.github.io/docs/configuration.html#entry
*/
export class WebpackEntry {
constructor(opts = {}) {
this.$entry = opts;
}
parse() {
return this.$entry;
}
}
/**
* module
* @description
* @see http://webpack.github.io/docs/configuration.html#module
*/
export class WebpackModule {
// http://webpack.github.io/docs/configuration.html#module-loaders
loaders = undefined;
// http://webpack.github.io/docs/configuration.html#module-preLoaders
preLoaders = undefined;
// http://webpack.github.io/docs/configuration.html#module-postLoaders
postLoaders = undefined;
// http://webpack.github.io/docs/configuration.html#module-noParse
noParse = undefined;
//
constructor(opts = {}) {
}
//
createContext(value, prefix, type) {
let prefixes = ['expr', 'wrapped'];
let stypes = ['', 'Request', 'Recursive', 'RegExp', 'Critical'];
prefix = typeof prefix === 'string' && ~prefixes.indexOf(prefix) ? prefix : 'unknown';
type = typeof type === 'string' ? stypes.indeOf(type.toLowerCase()) : type;
type = typeof type === 'number' && ~type ? type : 'None';
this[prefix +'Context'+ type] = value;
}
//
parse() {
}
}
/**
* output
* @description
* @see http://webpack.github.io/docs/configuration.html#output
*/
export class WebpackOutput {
// http://webpack.github.io/docs/configuration.html#output-filename
filename = 'bundle.js';
// The output directory as absolute path (required).
// http://webpack.github.io/docs/configuration.html#output-path
path = path.join(root, 'www');
// http://webpack.github.io/docs/configuration.html#output-publicPath
publicPath = '/';
// http://webpack.github.io/docs/configuration.html#output-chunkFilename
chunkFilename = undefined;
// http://webpack.github.io/docs/configuration.html#output-sourceMapFilename
sourceMapFilename = undefined;
// http://webpack.github.io/docs/configuration.html#output-devtoolModuleFilenameTemplate
devtoolModuleFilenameTemplate = undefined;
// http://webpack.github.io/docs/configuration.html#output-devtoolFallbackModuleFilenameTemplate
devtoolFallbackModuleFilenameTemplate = undefined;
// http://webpack.github.io/docs/configuration.html#output-devtoolLineToLine
devtoolLineToLine = undefined;
// http://webpack.github.io/docs/configuration.html#output-hotUpdateChunkFilename
hotUpdateChunkFilename = undefined;
// http://webpack.github.io/docs/configuration.html#output-hotUpdateMainFilename
hotUpdateMainFilename = undefined;
// http://webpack.github.io/docs/configuration.html#output-jsonpFunction
jsonpFunction = undefined;
// http://webpack.github.io/docs/configuration.html#output-hotUpdateFunction
hotUpdateFunction = undefined;
// http://webpack.github.io/docs/configuration.html#output-pathinfo
pathinfo = undefined;
// http://webpack.github.io/docs/configuration.html#output-library
library = undefined;
// http://webpack.github.io/docs/configuration.html#output-libraryTarget
libraryTarget = undefined;
// http://webpack.github.io/docs/configuration.html#output-umdNamedDefine
umdNamedDefine = undefined;
// http://webpack.github.io/docs/configuration.html#output-sourcePrefix
sourcePrefix = undefined;
// http://webpack.github.io/docs/configuration.html#output-crossOriginLoading
crossOriginLoading = undefined;
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* resolve
* @description Options affecting the resolving of modules.
* @see http://webpack.github.io/docs/configuration.html#resolve
*/
export class WebpackResolve {
// http://webpack.github.io/docs/configuration.html#resolve-alias
alias = undefined;
// http://webpack.github.io/docs/configuration.html#resolve-root
root = undefined;
// http://webpack.github.io/docs/configuration.html#resolve-modulesDirectories
modulesDirectories = undefined;
// http://webpack.github.io/docs/configuration.html#resolve-fallback
fallback = undefined;
// http://webpack.github.io/docs/configuration.html#resolve-extensions
extensions = undefined;
// http://webpack.github.io/docs/configuration.html#resolve-packageMains
packageMains = undefined;
// http://webpack.github.io/docs/configuration.html#resolve-packageAlias
packageAlias = undefined;
// http://webpack.github.io/docs/configuration.html#resolve-unsafeCache
unsafeCache = undefined;
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* resolveLoader
* @description
* @see
*/
export class WebPackResolveLoader {
// http://webpack.github.io/docs/configuration.html#resolveLoader-moduleTemplates
moduleTemplates = undefined;
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* externals
* @description
* @see
*/
export class WebpackExternals {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* target
* @description
* @see
*/
export class WebpackTarget {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* bail
* @description
* @see
*/
export class WebpackBail {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* profile
* @description
* @see
*/
export class WebpackProfile {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* cache
* @description
* @see
*/
export class WebpackCache {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* watch
* @description
* @see
*/
export class WebpackWatch {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* debug
* @description
* @see
*/
export class WebpackDebug {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* devtool
* @description
* @see
*/
export class WebpackDevTool {
constructor(opts = {}) {
}
parse() {
}
}
/**
* devServer
* @description
* @see
*/
export class WebpackDevServer {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* node
* @description
* @see
*/
export class WebpackNode {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* amd
* @description
* @see
*/
export class WebpackAMD {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* loader
* @description
* @see http://webpack.github.io/docs/configuration.html#loader
*/
export class WebpackLoader {
test = undefined;
loader = '';
include = '';
query = {};
constructor(opts = {}) {
}
parse() {
}
}
/**
* recordsPath
* @description
* @see http://webpack.github.io/docs/configuration.html#recordsPath
*/
export class WebpackRecordsPath {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* recordsInputPath
* @description
* @see http://webpack.github.io/docs/configuration.html#recordsInputPath
*/
export class WebpackRecordsInputPath {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* recordsOutputPath
* @description
* @see http://webpack.github.io/docs/configuration.html#recordsOutputPath
*/
export class WebpackRecordsOutputPath {
//
constructor(opts = {}) {
}
//
parse() {
}
}
/**
* plugins
* @description
* @see
*/
export class WebpackPlugins {
//
constructor(opts = {}) {
}
//
add() {
}
//
parse() {
}
}
/**
* configuration
* @description webpack is fed a configuration object.
* @see http://webpack.github.io/docs/configuration.html
*/
export class WebpackConfig {
//
constructor(opts = {}) {
this.resolveLoader = new WebPackResolveLoader(opts.resolveLoader);
this.externals = new WebPackExternals(opts.externals);
this.context = new WebpackContext(opts.context);
this.resolve = new WebpackResolve(opts.resolve);
this.plugins = new WebpackPlugins(opts.plugins);
this.devtool = new WebpackDevTool(opts.devtool);
this.module = new WebpackModule(opts.module);
this.output = new WebpackOutput(opts.output);
this.entry = new WebpackEntry(opts.entry);
}
//
parse() {
let opts = {};
for (let key in this) {
opts[key] = this[key].parse();
}
return opts;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment