Install theme to jupyter_customcss with specified font, fontsize,
    md layout, and toolbar pref
511282
def install_theme(theme=None,
                monofont=None,
                monosize=11,
                nbfont=None,
                nbfontsize=13,
                tcfont=None,
                tcfontsize=13,
                dffontsize=93,
                outfontsize=85,
                mathfontsize=100,
                margins='auto',
                cellwidth='980',
                lineheight=170,
                cursorwidth=2,
                cursorcolor='default',
                altprompt=False,
                altmd=False,
                altout=False,
                hideprompt=False,
                vimext=False,
                toolbar=False,
                nbname=False,
                kernellogo=False,
                dfonts=False):

    
    # get working directory
    wkdir = os.path.abspath('./')

    stylefx.reset_default(False)
    stylefx.check_directories()

    doc = '\nConcatenated font imports, .less styles, & custom variables\n'
    s = '*' * 65
    style_less = '\n'.join(['/*', s, s, doc, s, s, '*/'])
    style_less += '\n\n\n'
    style_less += '/* Import Notebook, Markdown, & Code Fonts */\n'

    # initialize style_less & style_css
    style_less = stylefx.set_font_properties(
        style_less=style_less,
        monofont=monofont,
        monosize=monosize,
        nbfont=nbfont,
        nbfontsize=nbfontsize,
        tcfont=tcfont,
        tcfontsize=tcfontsize,
        dffontsize=dffontsize,
        outfontsize=outfontsize,
        mathfontsize=mathfontsize,
        dfonts=dfonts)

    if theme is not None:
        # define some vars for cell layout
        cursorcolor = stylefx.get_colors(theme=theme, c=cursorcolor)
        style_less = stylefx.style_layout(
            style_less,
            theme=theme,
            cellwidth=cellwidth,
            margins=margins,
            lineheight=lineheight,
            altprompt=altprompt,
            altmd=altmd,
            altout=altout,
            hideprompt=hideprompt,
            cursorwidth=cursorwidth,
            cursorcolor=cursorcolor,
            vimext=vimext,
            toolbar=toolbar,
            nbname=nbname,
            kernellogo=kernellogo)

    # compile tempfile.less to css code and append to style_css
    style_css = stylefx.less_to_css(style_less)

    # append mathjax css & script to style_css
    style_css = stylefx.set_mathjax_style(style_css, mathfontsize)

    # install style_css to .jupyter/custom/custom.css
    stylefx.write_final_css(style_css)

    # change back to original working directory
    os.chdir(wkdir)
816563
def theme(name='readthedocs'):
    """"""
    
    os.environ['SPHINX_THEME'] = name
    if os.environ['SPHINX_THEME'] == 'bootstrap':
        local('cp docs/source/_templates/layout_bootstrap.html docs/source/_templates/layout.html')
    elif name is 'readthedocs':
        return
    else:
        local('cp docs/source/_templates/layout_simple.html docs/source/_templates/layout.html')
1230121
def install_custom_css( destdir, cssfile, resource=PKGNAME ):
    
    ensure_dir_exists( destdir )
    custom = os.path.join( destdir, 'custom.css' )
    prefix = css_frame_prefix(resource)

    # Check if custom.css already includes it. If so, let's remove it first
    exists = False
    if os.path.exists( custom ):
        with io.open(custom) as f:
            for line in f:
                if line.find( prefix ) >= 0:
                    exists = True
                    break
    if exists:
        remove_custom_css( destdir, resource )

    # Fetch the CSS file
    cssfile += '.css'
    data = pkgutil.get_data( resource, os.path.join('resources',cssfile) )
    # get_data() delivers encoded data, str (Python2) or bytes (Python3)

    # Add the CSS at the beginning of custom.css
    # io.open uses unicode strings (unicode in Python2, str in Python3)
    with io.open(custom + '-new', 'wt', encoding='utf-8') as fout:
        fout.write( u'{}START ======================== */\n'.format(prefix))
        fout.write( data.decode('utf-8') )
        fout.write( u'{}END ======================== */\n'.format(prefix))
        if os.path.exists( custom ):
            with io.open( custom, 'rt', encoding='utf-8' ) as fin:
                for line in fin:
                    fout.write( unicode(line) )
    os.rename( custom+'-new',custom)
311288
def install_templates(srcroot, destroot, prefix='', excludes=None,
                      includes=None, path_prefix=None):
    #pylint:disable=too-many-arguments,too-many-statements
    
    #pylint: disable=too-many-locals
    if excludes is None:
        excludes = []
    if includes is None:
        includes = []
    if not os.path.exists(os.path.join(prefix, destroot)):
        os.makedirs(os.path.join(prefix, destroot))
    for pathname in os.listdir(os.path.join(srcroot, prefix)):
        pathname = os.path.join(prefix, pathname)
        excluded = False
        for pat in excludes:
            if re.match(pat, pathname):
                excluded = True
                break
        if excluded:
            for pat in includes:
                if re.match(pat, pathname):
                    excluded = False
                    break
        if excluded:
            LOGGER.debug("skip %s", pathname)
            continue
        source_name = os.path.join(srcroot, pathname)
        dest_name = os.path.join(destroot, pathname)
        if os.path.isfile(source_name) and not os.path.exists(dest_name):
            # We don't want to overwrite specific theme files by generic ones.
            with open(source_name) as source:
                template_string = source.read()
            try:
                template_string = force_text(template_string)
                lexer = DebugLexer(template_string)
                tokens = lexer.tokenize()
                if not os.path.isdir(os.path.dirname(dest_name)):
                    os.makedirs(os.path.dirname(dest_name))
                engine, libraries, builtins = get_html_engine()
                if isinstance(engine, DjangoTemplates):
                    with open(dest_name, 'w') as dest:
                        parser = AssetsParser(tokens,
                            URLRewriteWrapper(dest, path_prefix),
                            libraries=libraries,
                            builtins=builtins,
                            origin=None)
                        parser.parse_through()
                else:
                    template_name = None
                    tokens = Lexer(engine.env).tokeniter(template_string,
                        template_name, filename=source_name)
                    buffered_tokens = []
                    state = None
                    with open(dest_name, 'w') as dest:
                        for token in tokens:
                            if state is None:
                                if token[1] == 'block_begin':
                                    state = STATE_BLOCK_BEGIN
                            elif state == STATE_BLOCK_BEGIN:
                                if token[1] == 'name':
                                    if token[2] == 'assets':
                                        state = STATE_ASSETS_BEGIN
                                    else:
                                        buffered_tokens += [token]
                                        state = None
                            elif state == STATE_ASSETS_BEGIN:
                                if (token[1] == 'name'
                                    and token[2] == 'endassets'):
                                    state = STATE_ASSETS_END
                            elif state == STATE_ASSETS_END:
                                if token[1] == 'block_end':
                                    buffered_tokens += [token]
                                    state = None
                            if state is None:
                                if buffered_tokens:
                                    for tok in buffered_tokens:
                                        if (tok[1] == 'name' and
                                            tok[2] == 'assets'):
                                            dest.write(_render_assets(
                                                buffered_tokens,
                                                engine.env.assets_environment))
                                            buffered_tokens = []
                                            break
                                    if buffered_tokens:
                                        dest.write("%s" % ''.join([token[2]
                                            for token in buffered_tokens]))
                                    buffered_tokens = []
                                else:
                                    dest.write("%s" % str(token[2]))
                            else:
                                buffered_tokens += [token]
                        if buffered_tokens:
                            dest.write("%s" % ''.join([
                                token[2] for token in buffered_tokens]))
                            buffered_tokens = []
                        dest.write("\n")

                cmdline = ['diff', '-u', source_name, dest_name]
                cmd = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
                lines = cmd.stdout.readlines()
                cmd.wait()
                # Non-zero error codes are ok here. That's how diff
                # indicates the files are different.
                if lines:
                    verb = 'compile'
                else:
                    verb = 'install'
                dest_multitier_name = dest_name.replace(destroot,
                        '*MULTITIER_TEMPLATES_ROOT*')
                LOGGER.debug("%s %s to %s", verb,
                    source_name.replace(
                        django_settings.BASE_DIR, '*APP_ROOT*'),
                    dest_multitier_name)
            except UnicodeDecodeError:
                LOGGER.warning("%s: Templates can only be constructed "
                    "from unicode or UTF-8 strings.", source_name)
        elif os.path.isdir(source_name):
            install_templates(srcroot, destroot, prefix=pathname,
                excludes=excludes, includes=includes, path_prefix=path_prefix)
619291
def set_pythonshell_font(self, font=None):
        """"""
        if font is None:
            font = QFont()
        for style in self.font_styles:
            style.apply_style(font=font,
                              is_default=style is self.default_style)
        self.ansi_handler.set_base_format(self.default_style.format)
1127790
function applyTheme(theme) {
        Object.keys(theme).forEach(function(prop) {
            if (prototypeBlacklist.indexOf(prop) >= 0) {
                return;
            }
            if (typeof theme[prop] == 'string') {
                // Multiple colours white-space seperated #45, e.g. "red bold", #18
                theme[prop] = theme[prop].split(' ');
            }
            addProperty(prop, function () {
                var ret = this;
                for (var t=0; t<theme[prop].length; t++) {
                    ret = colour[theme[prop][t]](ret);
                }
                return ret;
            });
        });
    }
1019704
function(options) {
    options.resources = {
        css: [],
        js: []
    };
    // - copy template css file
    options.resources.css.push(fileResolver(
        options,
        require.resolve('./resources/docco-template.css')
    ));
    // - copy jquery js file
    options.resources.js.push(fileResolver(
        options,
        require.resolve('jquery/dist/jquery.min.js')
    ));
    // - copy jstree distribution js
    options.resources.js.push(fileResolver(
        options,
        require.resolve('jstree/dist/jstree.js')
    ));
    // - copy jstree search plugin js
    options.resources.js.push(fileResolver(
        options,
        require.resolve('jstree/src/jstree.search.js')
    ));
    // - copy jstree distribution css
    options.resources.css.push(fileResolver(
        options,
        require.resolve('jstree/dist/themes/default-dark/style.min.css')
    ));
    // - copy jstree distribution images
    options.resources.css.push(fileResolver(
        options,
        require.resolve('jstree/dist/themes/default-dark/32px.png'),
        '32px.png'
    ));
    options.resources.css.push(fileResolver(
        options,
        require.resolve('jstree/dist/themes/default-dark/40px.png'),
        '40px.png'
    ));
    options.resources.css.push(fileResolver(
        options,
        require.resolve('jstree/dist/themes/default-dark/throbber.gif'),
        'throbber.gif'
    ));
    // - copy bootstrap js file
    options.resources.js.push(fileResolver(
        options,
        require.resolve('./resources/bootstrap.js')
    ));
    // - copy highlightjs style
    options.resources.css.push(fileResolver(
        options,
        require.resolve('highlight.js/styles/' + options.highlightStyle + '.css')
    ));
    // - copy markdown style
    options.resources.css.push(fileResolver(
        options,
        require.resolve('./resources/gfm.css')
    ));
    // -copy config.css
    if (options.css) {
        options.resources.css.push(fileResolver(
            options,
            options.css
        ));
    }
    return options;
}
145086
function installThemeDeps(root, options) {
  if (options.skipInstall) {
    console.log('Skipping theme dependency installation...');
    return Promise.resolve();
  }

  const prevDir = process.cwd();

  console.log('Installing theme dependencies...');
  process.chdir(root);

  const cmd = utils.shouldUseYarn()
    ? utils.spawn('yarnpkg')
    : utils.spawn('npm install');

  return cmd.then(() => process.chdir(prevDir));
}
1186645
function cssTemplate (params) {
  // Localize parameters
  var items = params.items;
  var options = params.options;
  var tmplParams = {
    sprite: null,
    retina: null,
    items: [],
    options: options
  };

  var classFn = function (name, sep) {
    if (options.cssClass) {
      return '.' + cssesc(options.cssClass + sep + name, {isIdentifier: true});
    }
    else {
      return '.icon' + cssesc(sep + name, {isIdentifier: true});
    }
  };

  // Add class to each of the options
  items.forEach(function saveClass (item) {
    if (item.type === 'sprite') {
      item['class'] = classFn('', '');
      tmplParams.sprite = item;
    }
    else if (item.type === 'retina') {
      item['class'] = classFn('', '');
      tmplParams.retina = item;
    }
    else {
      item['class'] = classFn(item.name, '-');
      tmplParams.items.push(item);
    }
  });
  // Render and return CSS
  var tmplFile = options.template ?
    fs.readFileSync(path.resolve(process.cwd(), options.template), 'utf8') :
    tmpl[options.processor];
  var css = mustache.render(tmplFile, tmplParams);
  return css;
}
1185173
def set_plot_theme(theme):
    """"""
    if theme.lower() in ['paraview', 'pv']:
        rcParams['background'] = PV_BACKGROUND
        rcParams['cmap'] = 'coolwarm'
        rcParams['font']['family'] = 'arial'
        rcParams['font']['label_size'] = 16
        rcParams['show_edges'] = False
    elif theme.lower() in ['document', 'doc', 'paper', 'report']:
        rcParams['background'] = 'white'
        rcParams['cmap'] = 'viridis'
        rcParams['font']['size'] = 18
        rcParams['font']['title_size'] = 18
        rcParams['font']['label_size'] = 18
        rcParams['font']['color'] = 'black'
        rcParams['show_edges'] = False
        rcParams['color'] = 'tan'
        rcParams['outline_color'] = 'black'
    elif theme.lower() in ['night', 'dark']:
        rcParams['background'] = 'black'
        rcParams['cmap'] = 'viridis'
        rcParams['font']['color'] = 'white'
        rcParams['show_edges'] = False
        rcParams['color'] = 'tan'
        rcParams['outline_color'] = 'white'
    elif theme.lower() in ['default']:
        for k,v in DEFAULT_THEME.items():
            rcParams[k] = v
1118298
def _append_theme_dir(self, name):
        """"""
        path = "[{}]".format(get_file_directory() + "/" + name)
        self.tk.call("lappend", "auto_path", path)
709917
def tweak_css(repo_dir):
    ''''''
    print_msg("* don't capitalize titles (no uppercase headings)")
    files = [
        'beige.css', 'black.css', 'blood.css', 'league.css', 'moon.css',
        'night.css', 'serif.css', 'simple.css', 'sky.css', 'solarized.css',
        'white.css',
    ]
    line = '  text-transform: uppercase;'
    for file_ in files:
        update_or_append_line(filename=flo('{repo_dir}/css/theme/{file_}'),
                              prefix=line, new_line=flo('/*{line}*/'))

    print_msg('* images without border')
    data = [
        {'file': 'beige.css',     'line': '  border: 4px solid #333;'},
        {'file': 'black.css',     'line': '  border: 4px solid #fff;'},
        {'file': 'blood.css',     'line': '  border: 4px solid #eee;'},
        {'file': 'league.css',    'line': '  border: 4px solid #eee;'},
        {'file': 'moon.css',      'line': '  border: 4px solid #93a1a1;'},
        {'file': 'night.css',     'line': '  border: 4px solid #eee;'},
        {'file': 'serif.css',     'line': '  border: 4px solid #000;'},
        {'file': 'simple.css',    'line': '  border: 4px solid #000;'},
        {'file': 'sky.css',       'line': '  border: 4px solid #333;'},
        {'file': 'solarized.css', 'line': '  border: 4px solid #657b83;'},
        {'file': 'white.css',     'line': '  border: 4px solid #222;'},
    ]
    for item in data:
        file_ = item['file']
        lines = [item['line'], ]
        lines.extend(['  box-shadow: 0 0 10px rgba(0, 0, 0, 0.15); }',
                      '  box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }'])
        for line in lines:
            update_or_append_line(filename=flo('{repo_dir}/css/theme/{file_}'),
                                  prefix=line, new_line=flo('/*{line}*/'))
319958
def _insert_html_configs(c, *, project_name, short_project_name):
    
    # Use the lsst-sphinx-bootstrap-theme
    c['templates_path'] = [
        '_templates',
        lsst_sphinx_bootstrap_theme.get_html_templates_path()]
    c['html_theme'] = 'lsst_sphinx_bootstrap_theme'
    c['html_theme_path'] = [lsst_sphinx_bootstrap_theme.get_html_theme_path()]

    # Theme options are theme-specific and customize the look and feel of a
    # theme further.  For a list of options available for each theme, see the
    # documentation.
    c['html_theme_options'] = {'logotext': short_project_name}

    # The name for this set of Sphinx documents.  If None, it defaults to
    # "<project> v<release> documentation".
    c['html_title'] = project_name

    # A shorter title for the navigation bar.  Default is the same as
    # html_title.
    c['html_short_title'] = short_project_name

    # The name of an image file (relative to this directory) to place at the
    # top of the sidebar.
    c['html_logo'] = None

    # The name of an image file (within the static path) to use as favicon of
    # the docs.  This file should be a Windows icon file (.ico) being 16x16 or
    # 32x32 pixels large.
    c['html_favicon'] = None

    # Add any paths that contain custom static files (such as style sheets)
    # here, relative to this directory. They are copied after the builtin
    # static files, so a file named "default.css" will overwrite the builtin
    # "default.css".
    if os.path.isdir('_static'):
        c['html_static_path'] = ['_static']
    else:
        # If a project does not have a _static/ directory, don't list it
        # so that there isn't a warning.
        c['html_static_path'] = []

    # Add any extra paths that contain custom files (such as robots.txt or
    # .htaccess) here, relative to this directory. These files are copied
    # directly to the root of the documentation.
    # html_extra_path = []

    # If not '', a 'Last updated on:' timestamp is inserted at every page
    # bottom, using the given strftime format.
    c['html_last_updated_fmt'] = '%b %d, %Y'

    # If true, SmartyPants will be used to convert quotes and dashes to
    # typographically correct entities.
    c['html_use_smartypants'] = True

    # If false, no module index is generated.
    c['html_domain_indices'] = False

    # If false, no index is generated.
    c['html_use_index'] = False

    # If true, the index is split into individual pages for each letter.
    c['html_split_index'] = False

    # If true, links to the reST sources are added to the pages.
    c['html_show_sourcelink'] = True

    # If true, "Created using Sphinx" is shown in the HTML footer. Default is
    # True.
    c['html_show_sphinx'] = True

    # If true, "(C) Copyright ..." is shown in the HTML footer. Default is
    # True.
    c['html_show_copyright'] = True

    # If true, an OpenSearch description file will be output, and all pages
    # will contain a <link> tag referring to it.  The value of this option must
    # be the base URL from which the finished HTML is served.
    # html_use_opensearch = ''

    # This is the file name suffix for HTML files (e.g. ".xhtml").
    c['html_file_suffix'] = '.html'

    # Language to be used for generating the HTML full-text search index.
    c['html_search_language'] = 'en'

    # A dictionary with options for the search language support, empty by
    # default.  Now only 'ja' uses this config value
    # html_search_options = {'type': 'default'}

    # The name of a javascript file (relative to the configuration directory)
    # that implements a search results scorer. If empty, the default will be
    # used.
    # html_search_scorer = 'scorer.js'

    return c
413359
def create_pygments_dict(color_scheme_name):
    

    def give_font_weight(is_bold):
        if is_bold:
            return 'bold'
        else:
            return ''

    def give_font_style(is_italic):
        if is_italic:
            return 'italic'
        else:
            return ''

    color_scheme = get_color_scheme(color_scheme_name)

    fon_c, fon_fw, fon_fs = color_scheme['normal']
    font_color =  fon_c
    font_font_weight = give_font_weight(fon_fw)
    font_font_style = give_font_style(fon_fs)
    key_c, key_fw, key_fs = color_scheme['keyword']
    keyword_color =  key_c
    keyword_font_weight = give_font_weight(key_fw)
    keyword_font_style = give_font_style(key_fs)
    bui_c, bui_fw, bui_fs = color_scheme['builtin']
    builtin_color =  bui_c
    builtin_font_weight = give_font_weight(bui_fw)
    builtin_font_style = give_font_style(bui_fs)
    str_c, str_fw, str_fs = color_scheme['string']
    string_color =  str_c
    string_font_weight = give_font_weight(str_fw)
    string_font_style = give_font_style(str_fs)
    num_c, num_fw, num_fs = color_scheme['number']
    number_color =  num_c
    number_font_weight = give_font_weight(num_fw)
    number_font_style = give_font_style(num_fs)
    com_c, com_fw, com_fs = color_scheme['comment']
    comment_color =  com_c
    comment_font_weight = give_font_weight(com_fw)
    comment_font_style = give_font_style(com_fs)
    def_c, def_fw, def_fs = color_scheme['definition']
    definition_color =  def_c
    definition_font_weight = give_font_weight(def_fw)
    definition_font_style = give_font_style(def_fs)
    ins_c, ins_fw, ins_fs = color_scheme['instance']
    instance_color =  ins_c
    instance_font_weight = give_font_weight(ins_fw)
    instance_font_style = give_font_style(ins_fs)

    font_token = font_font_style + ' ' + font_font_weight + ' ' + font_color
    definition_token = (definition_font_style + ' ' + definition_font_weight +
                        ' ' + definition_color)
    builtin_token = (builtin_font_style + ' ' + builtin_font_weight + ' ' +
                     builtin_color)
    instance_token = (instance_font_style + ' ' + instance_font_weight + ' ' +
                      instance_color)
    keyword_token = (keyword_font_style + ' ' + keyword_font_weight + ' ' +
                     keyword_color)
    comment_token = (comment_font_style + ' ' + comment_font_weight + ' ' +
                     comment_color)
    string_token = (string_font_style + ' ' + string_font_weight + ' ' +
                    string_color)
    number_token = (number_font_style + ' ' + number_font_weight + ' ' +
                    number_color)

    syntax_style_dic = {Name: font_token.strip(),
                        Name.Class: definition_token.strip(),
                        Name.Function: definition_token.strip(),
                        Name.Builtin: builtin_token.strip(),
                        Name.Builtin.Pseudo: instance_token.strip(),
                        Keyword: keyword_token.strip(),
                        Keyword.Type: builtin_token.strip(),
                        Comment: comment_token.strip(),
                        String: string_token.strip(),
                        Number: number_token.strip(),
                        Punctuation: font_token.strip(),
                        Operator.Word: keyword_token.strip()}

    return syntax_style_dic
299371
def setup(app):
    
    try:
        app.info('adding bolditalic role...', nonl=True)
        app.add_role('bolditalic', bolditalic)
        app.connect('env-updated', css)
        app.info(' done')
    except Exception:
        app.warn('Failed to initialize bolditalic styling.')
    return {
        'version': __version__,
        'parallel_read_safe': True,
        'parallel_write_safe': True,
        }
1165619
def makeHTML(self,mustachepath,htmlpath):
        ''' '''
        subs = dict()
        if self.title:
            subs["title"]=self.title
            subs["has_title"]=True
        else:
            subs["has_title"]=False
        subs["font_size"] = self.font_size
        subs["font_family"] = self.font_family
        subs["colorscheme"] = self.colorscheme
        subs["title_color"] = self.title_color
        subs["bgcolor"] = self.bgcolor
        with open(mustachepath,'r') as infile:
            mustache_text = pystache.render(infile.read(), subs)
            with open(htmlpath,'w+') as outfile:
                outfile.write(mustache_text)
403659
function buildCSS(src, filename, dest, applyHeader) {
  dest = dest || config.dist.cssPath;
  applyHeader = applyHeader || false;

  return gulp.src(src)
    .pipe(sass({
      includePaths: [config.src.scssPath, config.packagesPath]
    })
      .on('error', sass.logError))
    .pipe(cleanCSS())
    .pipe(autoprefixer({
      // Supported browsers added in package.json ("browserslist")
      cascade: false
    }))
    .pipe(gulpif(applyHeader, header(config.prj.header, {
      config: config
    })))
    // Remove charset rule (if present) and add to the first
    // line of the stylesheet (@charset must be on the first line)
    .pipe(replace('@charset "UTF-8";', ''))
    .pipe(header('@charset "UTF-8";\n'))
    .pipe(rename(filename))
    .pipe(gulp.dest(dest));
}