Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Vue.js script setup syntax #1604

Open
mustafadalga opened this issue Jun 1, 2023 · 1 comment
Open

Support for Vue.js script setup syntax #1604

mustafadalga opened this issue Jun 1, 2023 · 1 comment

Comments

@mustafadalga
Copy link

Issue:

I have encountered a problem where documentation.js is not able to generate documentation for Vue components when using the script setup syntax. However, it works correctly for traditional Vue components using <script lang="ts">.

The code snippet below is an example of a Vue component that documentation.js correctly generates documentation for:

<script lang="ts">
/**
 * A simple button component
 * @constructor Button
 */

/**
 * props variables
 *
 * @property {string} color - background color of the button
 * @property {number} width - button width
 * @property {number} height - button height
 * @property {Function} sum - sum function that takes x and y and returns the sum of x and y
 */
const props = defineProps({
  color: {
    type: String,
    required: true,
  },
  width: Number,
  height: Number,
  sum: {
    type: Function,
    required: true,
  },
});

/**
 * This method logs the input parameters to the console.
 * @param {string} text - user text input
 */
function summarize(text) {
  console.log("summarization...");
}

/**
 * The function
 * @param {number} x - one input number
 * @returns {number} This is the result
 */
function increase(x) {
  return x + 1;
}
</script>

However, when the same Vue component is written with the script setup syntax, documentation.js is unable to generate documentation:

<script setup lang="ts">
/**
 * A simple button component
 * @constructor Button
 */

/**
 * props variables
 *
 * @property {string} color - background color of the button
 * @property {number} width - button width
 * @property {number} height - button height
 * @property {Function} sum - sum function that takes x and y and returns the sum of x and y
 */
const props = defineProps({
  color: {
    type: String,
    required: true,
  },
  width: Number,
  height: Number,
  sum: {
    type: Function,
    required: true,
  },
});

/**
 * This method logs the input parameters to the console.
 * @param {string} text - user text input
 */
function summarize(text) {
  console.log("summarization...");
}

/**
 * The function
 * @param {number} x - one input number
 * @returns {number} This is the result
 */
function increase(x) {
  return x + 1;
}
</script>

Expected Output:
I expected documentation.js to generate the same documentation as it does for the traditional script syntax, including documentation for props, methods, and any additional jsdoc/tsdoc comments.

I believe the issue lies in the lack of support for the Vue.js script setup syntax. I'd appreciate it if the support for this syntax could be added to the tool. Thank you!

Environment:

What version of documentation.js are you using?: 14.0.2
How are you running documentation.js (on the CLI, Node.js API, Grunt, other?): CLI
Node.js version: v19.9.0
Vue version: 3.2.45
TypeScript version: 4.7.4
OS: macOS
@mustafadalga
Copy link
Author

I have developed a npm package as workaround.
https://www.npmjs.com/package/vue-setup-doc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant