JS Doc评论链接方法

时间:2017-11-03 04:43:13

标签: javascript jsdoc

在JavaScript评论中,我想提一下某个文件中存在的方法。如何在评论中链接到该方法?例如

说我的方法是:

function xyz() {
}

并说我正在撰写评论

// See also {method-link to xyz}

{method-link}应该是什么?

1 个答案:

答案 0 :(得分:1)

链接到"其他内容"在JSDoc中,包括另一种方法,使用{@link ...}标记。在您的情况下,您将使用:

pdf.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

/////
                String FILE = Environment.getExternalStorageDirectory().toString()
                        + "/PDF/" + list.get(position).getTitle()+".pdf";

                // Add Permission into Manifest.xml
                // <uses-permission
                // android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

                // Create New Blank Document
                Document document = new Document(PageSize.A4);

                // Create Directory in External Storage
                String root = Environment.getExternalStorageDirectory().toString();
                File myDir = new File(root + "/PDF");
                myDir.mkdirs();

                // Create Pdf Writer for Writting into New Created Document
                try {
                    PdfWriter.getInstance(document, new FileOutputStream(FILE));

                    // Open Document for Writting into document
                    document.open();

                    // User Define Method
                 //document.add(list.get(position).getDate());
                addMetaData(document);
                addTitlePage(document,list.get(position).getDate(),list.get(position).getTitle(),list.get(position).getContent(),list.get(position).getPicture());
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (DocumentException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                // Close Document after writting all content
                document.close();

                //Toast.makeText(this, "PDF File is Created. Location : " + FILE,
                  //      Toast.LENGTH_LONG).show();

                //////
            }
        });



// Set PDF document Properties
public void addMetaData(Document document) {
document.addTitle("All memories");
}
public void addTitlePage(Document document,String date, String title, String content, String picture) throws DocumentException, IOException {
    // Font Style for Document
    Font catFont = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD);
    Font titleFont = new Font(Font.FontFamily.TIMES_ROMAN, 22, Font.BOLD
            | Font.UNDERLINE, BaseColor.GRAY);
    Font smallBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
    Font normal = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL);

    // Start New Paragraph
    Paragraph prHead = new Paragraph();
    // Set Font in this Paragraph
    prHead.setFont(titleFont);
    // Add item into Paragraph
    prHead.add("All Memories");
    //prHead.add(date + "\n");
    // Create Table into Document with 1 Row
    PdfPTable myTable = new PdfPTable(1);
    // 100.0f mean width of table is same as Document size
    myTable.setWidthPercentage(100.0f);

    // Create New Cell into Table
    PdfPCell myCell = new PdfPCell(new Paragraph(""));
    myCell.setBorder(Rectangle.BOTTOM);

    // Add Cell into Table
    myTable.addCell(myCell);

    prHead.setFont(catFont);
    //prHead.add("\nName1 Name2\n");
    prHead.setAlignment(Element.ALIGN_CENTER);

    // Add all above details into Document
    document.add(prHead);
    document.add(myTable);

    document.add(myTable);

    // Now Start another New Paragraph
    Paragraph prPersinalInfo = new Paragraph();
    prPersinalInfo.setFont(smallBold);
    prPersinalInfo.add(date+"\n");
    prPersinalInfo.add(title+"\n");
    prPersinalInfo.add(content+"\n");


// Convert the Image to Bitmap

if(picture!=null) {
Image img = Image.getInstance(picture);


img.setAlignment(Image.ALIGN_CENTER | Image.ALIGN_BOTTOM);

prPersinalInfo.add(img);
}
        // Convert the Image to Bitmap

// Convert the Image to Bitmap

    prPersinalInfo.setAlignment(Element.ALIGN_CENTER);

    document.add(prPersinalInfo);
    document.add(myTable);

    document.add(myTable);

    // Create new Page in PDF
    document.newPage();
}

然后,您可以在WebStorm中按住Ctrl键并单击// See also {@link xyz}

JSDoc的术语&#34;其他东西&#34;是&#34; namepath&#34;。下面是安德鲁的原始答案,它解释了名称路径。

JSDoc3个样式:

JSDoc 3中的名称路径的基本语法示例

xyz

特殊情况:模块,外部和事件。

myFunction
MyConstructor
MyConstructor#instanceMember
MyConstructor.staticMember
MyConstructor~innerMember // note that JSDoc 2 uses a dash

为了便于编码,我有时会在评论中使用/** A module. Its name is module:foo/bar. * @module foo/bar */ /** The built in string object. Its name is external:String. * @external String */ /** An event. Its name is module:foo/bar.event:MyEvent. * @event module:foo/bar.event:MyEvent */ 样式:

markdown