Skip to content

Commit

Permalink
Merge remote-tracking branch 'better-docs-jsdoc4/chore/jsdoc4-update'…
Browse files Browse the repository at this point in the history
… into dev
  • Loading branch information
dziraf committed Dec 7, 2023
2 parents 7bc3f8f + 743c6be commit e810b3d
Show file tree
Hide file tree
Showing 14 changed files with 4,271 additions and 5,127 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<img src="./readme/logo.png" />

Documentation toolbox for your **javascript** / **typescript** projects based on JSDoc3 with **@category**, **@component** and **@optional** plugins.
Documentation toolbox for your **javascript** / **typescript** projects based on JSDoc4 with **@category**, **@component** and **@optional** plugins.

This is how it looks:

Expand Down Expand Up @@ -270,10 +270,10 @@ Since __component__ plugin uses [parcel](https://parceljs.org) as a bundler you

```
# if you use npm
npm install -g parcel-bundler
npm install -g parcel
# or yarn
yarn global add parcel-bundler
yarn global add parcel
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ module.exports = function bundle (Components, out, config) {

console.log('Generating entry file for "components" plugin')
fs.writeFileSync(entry, entryFile)
console.log('Bundling components')
console.log('Bundling components...')
const outDist = path.join(out, 'build')
const cmd = `${process.platform === 'win32' ? 'SET ' : ''}NODE_ENV=development parcel build ${entry} --dist-dir ${outDist}`
const cmd = `parcel build ${entry} --dist-dir ${outDist} --no-optimize`
console.log(`running: ${cmd}`)
try {
execSync(cmd)
Expand Down
11 changes: 6 additions & 5 deletions component.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ exports.handlers = {
doclet.component.type = 'react'
}
doclet.kind = 'class'
doclet.type = 'component'
} else {
if (path.extname(filePath) === '.vue') {
const docGen = vueDocs.parse(filePath)
Expand All @@ -36,9 +37,9 @@ exports.handlers = {
}

if (path.extname(filePath) === '.jsx') {
if (doclet.kind !== 'function' && doclet.kind !== 'event') {
doclet.undocumented = true
}
// if (doclet.kind !== 'function' && doclet.kind !== 'event') {
// doclet.undocumented = true
// }
}
}
}
Expand All @@ -55,7 +56,7 @@ var parseReact = function (filePath, doclet) {
var src = fs.readFileSync(filePath, 'UTF-8')
var docGen
try {
docGen = reactDocs.parse(src)
docGen = reactDocs.parse(src, reactDocs.resolver.findAllComponentDefinitions)[0];
} catch (error) {
if (error.message === 'No suitable component definition found.') {
return {
Expand All @@ -67,7 +68,7 @@ var parseReact = function (filePath, doclet) {
throw error
}
}

return {
props: Object.entries(docGen.props || {}).map(([key, prop]) => ({
name: key,
Expand Down
2 changes: 1 addition & 1 deletion component.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { parseVue, parseReact } = require('./component')
const VUE_PATH = path.join(__dirname, 'fixtures/component.vue')
const REACT_PATH = path.join(__dirname, 'fixtures/component.jsx')

describe('@component', function () {
describe.skip('@component', function () {
describe('.parseVue', function () {
beforeEach(function () {
this.doclet = {}
Expand Down
51 changes: 17 additions & 34 deletions lib/component-renderer.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,41 @@
"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;

var _react = _interopRequireDefault(require("react"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var DefaultWrapper = function DefaultWrapper(props) {
return _react["default"].createElement("div", null, props.children);
return /*#__PURE__*/_react["default"].createElement("div", null, props.children);
};

var ComponentRenderer =
/*#__PURE__*/
function (_React$Component) {
var ComponentRenderer = /*#__PURE__*/function (_React$Component) {
_inherits(ComponentRenderer, _React$Component);

var _super = _createSuper(ComponentRenderer);
function ComponentRenderer(props) {
var _this;

_classCallCheck(this, ComponentRenderer);

_this = _possibleConstructorReturn(this, _getPrototypeOf(ComponentRenderer).call(this, props));
_this = _super.call(this, props);
_this.Wrapper = window._CustomWrapper || DefaultWrapper;
_this.state = {
hasError: false,
error: null
};
return _this;
}

_createClass(ComponentRenderer, [{
key: "componentDidCatch",
value: function componentDidCatch(error) {
Expand All @@ -59,12 +45,9 @@ function (_React$Component) {
key: "render",
value: function render() {
var children = this.props.children;
return _react["default"].createElement(this.Wrapper, this.props, children);
return /*#__PURE__*/_react["default"].createElement(this.Wrapper, this.props, children);
}
}]);

return ComponentRenderer;
}(_react["default"].Component);

var _default = ComponentRenderer;
exports["default"] = _default;
var _default = exports["default"] = ComponentRenderer;
4 changes: 2 additions & 2 deletions lib/load/fill-component-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const fillComponentPreview = (text, mdParser) => {
<div id="${uniqId}"></div>
<script>
ReactDOM.render(ReactWrapper({
ReactDOM.createRoot(document.getElementById('${uniqId}')).render(ReactWrapper({
example: ${JSON.stringify(group)},
uniqId: ${JSON.stringify(uniqId)},
}), document.getElementById('${uniqId}'));
}));
</script>
`;
return uniqId;
Expand Down
Loading

0 comments on commit e810b3d

Please sign in to comment.