简体   繁体   中英

How to add code reference in comments line in android studio?

I want to add code reference in comments docs like following screen shoot.

在此处输入图像描述


But this result I got

在此处输入图像描述

I really glad if someone guide me some gits or useful links for results that I want. Thanks

did u created the type name of showPartialLoading() and showFullScreenLoading() ?

because If you surround things like variable, method, or type names in square brackets, then dart doc will look up the name and link to its docs even from a different file in the same project doc. make sure that all identifiers exist so the comment can be referenced.

example:

///if you control + click this -> [MyApp] it will bring you to MyApp Class name

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

PS: idk why in StackOverflow code preview (markdown) doesn't show the color difference but if you run it in the dart file I'm sure it works.

Hope this will help.

more info:
https://dart.dev/guides/language/effective-dart/documentation
https://dart.dev/tools/linter-rules#comment_references
https://youtu.be/zLzlSVD85GA

I am coming a little bit late,

So, linking comment are only allowed outside of the blocks.

As you can see, the first one is outside the class' block, If you put your linking comment outside of any block inside the dart file, will work in any other case, it won't.

///Outside class' block [hello] => THIS WILL WORK
class ClassName {
///Inside class' block [hello] => THIS WON'T WORK

  void hello(){
  }
 
}

Hope I helped :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM