@@ -20,6 +20,8 @@ export default async function propHandler(documentation: Documentation, path: No
2020 return
2121 }
2222
23+ const modelPropertyName = getModelPropName ( path )
24+
2325 const propsValuePath = propsPath [ 0 ] . get ( 'value' )
2426
2527 if ( bt . isObjectExpression ( propsValuePath . node ) ) {
@@ -38,9 +40,10 @@ export default async function propHandler(documentation: Documentation, path: No
3840 const jsDocTags : BlockTag [ ] = jsDoc . tags ? jsDoc . tags : [ ]
3941
4042 // if it's the v-model describe it only as such
41- const propName = jsDocTags . some ( t => t . title === 'model' )
42- ? 'v-model'
43- : propNode . key . name || propNode . key . value
43+ const propertyName = propNode . key . name || propNode . key . value
44+ const isPropertyModel =
45+ jsDocTags . some ( t => t . title === 'model' ) || propertyName === modelPropertyName
46+ const propName = isPropertyModel ? 'v-model' : propertyName
4447
4548 const propDescriptor = documentation . getPropDescriptor ( propName )
4649
@@ -226,3 +229,33 @@ export function extractValuesFromTags(propDescriptor: PropDescriptor) {
226229 delete propDescriptor . tags [ 'values' ]
227230 }
228231}
232+
233+ /**
234+ * extract the property model.prop from the component object
235+ * @param path component NodePath
236+ * @returns name of the model prop, null if none
237+ */
238+ function getModelPropName ( path : NodePath ) : string | null {
239+ const modelPath = path
240+ . get ( 'properties' )
241+ . filter ( ( p : NodePath ) => bt . isObjectProperty ( p . node ) && getMemberFilter ( 'model' ) ( p ) )
242+
243+ if ( ! modelPath . length ) {
244+ return null
245+ }
246+
247+ const modelPropertyNamePath =
248+ modelPath . length &&
249+ modelPath [ 0 ]
250+ . get ( 'value' )
251+ . get ( 'properties' )
252+ . filter ( ( p : NodePath ) => bt . isObjectProperty ( p . node ) && getMemberFilter ( 'prop' ) ( p ) )
253+
254+ if ( ! modelPropertyNamePath . length ) {
255+ return null
256+ }
257+
258+ const valuePath = modelPropertyNamePath [ 0 ] . get ( 'value' )
259+
260+ return bt . isStringLiteral ( valuePath . node ) ? valuePath . node . value : null
261+ }
0 commit comments