0

I need to get jsdoc in runtime like this

/**
 * this is my class
 */
class Foo { }
// getJsDoc(Foo) ==> 'this is my class\n'

I am using typescript actually, I noticed during compile, ts copy TSdoc to target .js file, so if I can access using typescript, it is also ok

Cheng Bao
  • 161
  • 1
  • 4
  • 2
    Not easily. It's require source code parsing, which is a very tricky subject. This is an X/Y problem: I'd highly recommend figuring out a different approach for whatever you're trying to accomplish. – CertainPerformance Apr 01 '21 at 18:03
  • 1
    1) write a parser for js and jsoc (including tokenizer, ...). 2) parse your file. 3) create the logic to link jsdoc to it's code parts. 4) create a data table with all your needed jsdocs and make it accesable to your script. 5) write a function to find the specific part in that data table – Kai Lehmann Apr 01 '21 at 18:07

0 Answers0