Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
// This file is part of Moodle - http://moodle.org/
2
//
3
// Moodle is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// Moodle is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
/**
17
 * Helper functions for working with Moodle component names, directories, and sources.
18
 *
19
 * @copyright  2019 Andrew Nicols <andrew@nicols.co.uk>
20
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21
 */
22
 
23
"use strict";
24
/* eslint-env node */
25
 
26
// Do not include any plugins as stanard.
27
const plugins = [];
28
 
29
plugins.push('plugins/markdown');
30
 
31
/**
32
 * Get the source configuration.
33
 *
34
 * @return {Object}
35
 */
36
const getSource = () => {
37
    const glob = require('glob');
38
    const path = require('path');
39
    const ComponentList = require(path.resolve('.grunt/components.js'));
40
    const thirdPartyPaths = ComponentList.getThirdPartyPaths();
41
 
42
    const source = {
43
        include: [],
44
        includePattern: ".+\\.js$",
45
    };
46
 
47
    let includeList = [];
48
 
49
    ComponentList.getAmdSrcGlobList().forEach(async pattern => {
50
        includeList.push(...glob.sync(pattern));
51
    });
52
 
53
    const cwdLength = process.cwd().length + 1;
54
    includeList.forEach(path => {
55
        if (source.include.indexOf(path) !== -1) {
56
            // Ensure no duplicates.
57
            return;
58
        }
59
 
60
        const relPath = path.substring(cwdLength);
61
        if (thirdPartyPaths.indexOf(relPath) !== -1) {
62
            return;
63
        }
64
 
65
        source.include.push(path);
66
    });
67
 
68
    source.include.push('.grunt/jsdoc/README.md');
69
    return source;
70
};
71
 
72
const tags = {
73
    // Allow the use of unknown tags.
74
    // We have a lot of legacy uses of these.
75
    allowUnknownTags: true,
76
 
77
    // We make use of jsdoc and closure dictionaries as standard.
78
    dictionaries: [
79
        'jsdoc',
80
        'closure',
81
    ],
82
};
83
 
84
// Template configuraiton.
85
const templates = {
86
    cleverLinks: false,
87
    monospaceLinks: false,
88
};
89
 
90
module.exports = {
91
    opts: {
92
        destination: "./jsdoc/",
93
        template: "node_modules/docdash",
94
    },
95
    plugins,
96
    recurseDepth: 10,
97
    source: getSource(),
98
    sourceType: 'module',
99
    tags,
100
    templates,
101
    docdash: {
102
        collapse: true,
103
        search: true,
104
        sort: true,
105
        sectionOrder: [
106
            "Namespaces",
107
            "Modules",
108
            "Events",
109
            "Classes",
110
            "Externals",
111
            "Mixins",
112
            "Tutorials",
113
            "Interfaces"
114
        ],
115
        "menu": {
116
            "Developer Docs": {
117
                href: "https://moodledev.io",
118
                target: "_blank",
119
                "class": "menu-item",
120
                id: "devdocs"
121
            },
122
            "MDN Docs": {
123
                href: "https://developer.mozilla.org/en-US/docs/Web/JavaScript",
124
                target: "_blank",
125
                "class": "menu-item",
126
                id: "mdndocs",
127
            },
128
        },
129
        typedefs: true,
130
    },
131
};