<commit_before>module TypeDoc.Output
{
    /**
     * A plugin that loads all partials of the current theme.
     *
     * Partials must be placed in the ´partials´ subdirectory of the theme. The plugin first
     * loads the partials of the default theme and then the partials of the current theme.
     */
    export class PartialsPlugin extends BasePlugin
    {
        /**
         * Create a new PartialsPlugin instance.
         *
         * @param renderer  The renderer this plugin should be attached to.
         */
        constructor(renderer:Renderer) {
            super(renderer);
            renderer.on(Renderer.EVENT_BEGIN, this.onRendererBegin, this);
        }


        /**
         * Load all files in the given directory and registers them as partials.
         *
         * @param path  The path of the directory that should be scanned.
         */
        private loadPartials(path:string) {
            FS.readdirSync(path).forEach((fileName:string) => {
                var file = Path.join(path, fileName);
                var name = Path.basename(fileName, Path.extname(fileName));
                Handlebars.registerPartial(name, Renderer.readFile(file));
            });
        }


        /**
         * Triggered before the renderer starts rendering a project.
         *
         * @param event  An event object describing the current render operation.
         */
        private onRendererBegin(event:DocumentEvent) {
            var themePath = Path.join(this.renderer.theme.basePath, 'partials');
            var defaultPath = Path.join(Renderer.getDefaultTheme(), 'partials');

            if (themePath != defaultPath) {
                this.loadPartials(defaultPath);
            }

            this.loadPartials(themePath);
        }
    }<commit_msg>Bugfix: Partials plugin fails if /partials/ does not exist<commit_after>module TypeDoc.Output
{
    /**
     * A plugin that loads all partials of the current theme.
     *
     * Partials must be placed in the ´partials´ subdirectory of the theme. The plugin first
     * loads the partials of the default theme and then the partials of the current theme.
     */
    export class PartialsPlugin extends BasePlugin
    {
        /**
         * Create a new PartialsPlugin instance.
         *
         * @param renderer  The renderer this plugin should be attached to.
         */
        constructor(renderer:Renderer) {
            super(renderer);
            renderer.on(Renderer.EVENT_BEGIN, this.onRendererBegin, this);
        }


        /**
         * Load all files in the given directory and registers them as partials.
         *
         * @param path  The path of the directory that should be scanned.
         */
        private loadPartials(path:string) {
            if (!FS.existsSync(path) || !FS.statSync(path).isDirectory()) {
                return;
            }

            FS.readdirSync(path).forEach((fileName:string) => {
                var file = Path.join(path, fileName);
                var name = Path.basename(fileName, Path.extname(fileName));
                Handlebars.registerPartial(name, Renderer.readFile(file));
            });
        }


        /**
         * Triggered before the renderer starts rendering a project.
         *
         * @param event  An event object describing the current render operation.
         */
        private onRendererBegin(event:DocumentEvent) {
            var themePath = Path.join(this.renderer.theme.basePath, 'partials');
            var defaultPath = Path.join(Renderer.getDefaultTheme(), 'partials');

            if (themePath != defaultPath) {
                this.loadPartials(defaultPath);
            }

            this.loadPartials(themePath);
        }
    }
{'fraction_non_alphanumeric': 0.08729311265349707, 'fraction_numerical': 0.0, 'mean_word_length': 1.9136858475894245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '665180', 'n_tokens_mistral': 955, 'n_tokens_neox': 940, 'n_words': 282}