question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Leading comments are treated as trailing comments to the previous function body

See original GitHub issue

Hello,

I’m trying to parse the following file:

<?php
/** function 1 summary
 * @param Type $var Description
 **/
function FunctionName1(Type $var = null)
{
}

/** function 2 summary
 * @param Type $var Description
 **/
function FunctionName2(Type $var = null)
{
}

The output of the library is as follows:

...
{
  "kind": "function",
  "leadingComments": [{"kind": "commentblock","value": "/** function 1 summary\r\n * @param Type $var Description\r\n **/"}],
  "name": {
    "kind": "identifier",
    "name": "FunctionName1"
  },
  ...
  "body": {
    "kind": "block",
    "children": [],
    "trailingComments": [{"kind": "commentblock","value": "/** function 2 summary\r\n * @param Type $var Description\r\n **/"}]
  }
}
...

The problem is that the documentation of the FunctionName2 is treated as a trailing comment on the body of FunctionName1 instead of a leading comment on FunctionName2.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ichiriaccommented, Apr 10, 2019

@danilopolani, it’s normal, actually not yet released - will be done this week-end

1reaction
ichiriaccommented, Jan 22, 2019

Hi @aameen951,

The bug should be fixed from my latest commit - it will be released soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why are Comment nodes treated differently than any other ...
Comment nodes are contained within the comments member of a block node, whereas most other nodes live inside the body member of a...
Read more >
Programming - Commenting - Utah School of Computing
The top of any program file. This is called the "Header Comment". · Above every function. This is called the function header and...
Read more >
Style and recommendations of commenting code
trailing comments explaining fields in data structures (apart from those, I don't really use single line comments); exceptional or purpose- ...
Read more >
Documenting the code - Doxygen Manual
How to put comments in your code such that doxygen incorporates them in the ... of all comment blocks found within the body...
Read more >
Go Doc Comments - The Go Programming Language
“Doc comments” are comments that appear immediately before top-level package, const, func, type, and var declarations with no intervening newlines.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found