Are magic constants documented? (eg __FILE__, __DIR__, etc) - crystal-lang

Accidentally, in the crystal lang github issues, I found out about __FILE__ and __DIR__ able to be used in and outside of macros. I don't remember reading about them. Have they been documented anywhere?

The documentation has been published: https://crystal-lang.org/docs/syntax_and_semantics/constants.html
Original issue: https://github.com/crystal-lang/crystal-book/pull/138

Related

Two independent specs seem to interfere. Can someone tell me why?

I have two specs below:
spec/domain/cve/id_spec.cr
spec/domain/cwe/id_spec.cr
Only 'cve' and 'cwe' differ; the others are the same.
When I ran them one by one below,
crystal spec spec/domain/cve/id_spec.cr
crystal spec spec/domain/cwe/id_spec.cr
all examples passed.
However, when I did at a time below,
crystal spec spec/domain/cve/id_spec.cr spec/domain/cwe/id_spec.cr
examples in the 'cve' spec failed.
I've found crystal spec is doubtful, so posted an issue to the GitHub repository.
A set of reproducible minimum codes is in another repository.
The description below is obsolete.
Both Domain::CVE::ID and Domain::CWE::ID have the same methods, which are parse(string) and ==(other).
Did the crystal spec runner misread 'V' and 'W' as humans do? Really?
Now I've replaced the name ID with the fully qualified Domain::CVE::ID, and commented out include Domain::CVE, then I get all the examples passed.
Does someone tell me how to use include and not qualified constants?
The version I've used is:
Crystal 1.6.1 (2022-10-21)
LLVM: 14.0.6
Default target: aarch64-apple-darwin21.6.0
Thank you.

Is there a simple way to count documented functions in a library?

Is there a simple way to count how many functions, methods and/or classes there are in a library? And how many are documented? Maybe through Doxygen output?
When I try to Google a solution all I get is algorithms to count things... :)
There is a tool named Coverxygen which requires XML output from Doxygen.
Install it by:
pip install coverxygen
Bonus:
If you use Sphinx and Doxygen (and Breathe) to generate documentations, you can use DocsCov to make a badge showing documentation coverage to show on your README.
As Xin Huang pointed out in a comment above, there is a useful tool called doxy-coverage.py at https://github.com/alobbs/doxy-coverage. It prints, for each file documented with Doxygen, it prints how many entities it has (namespaces, free functions, classes, member functions, enums, #defines, etc) and how many of those are documented. It lists each of the non-documented entities. At the bottom it gives a summary of the documentation coverage (percent entities that are documented). It uses the XML output of Doxygen to do so.
I replaced the line
print("%d%% API documentation coverage" %(total_per))
by
print ('%3d%% API documentation coverage (%d of %d)'%(total_per, total_yes, total_all))
To add the total number of entities and total number of documented entities in the project.
It seems possible to modify the tool to distinguish entities by type. If I ever do this, I'll post the resulting code here.

What does this mean in a Constructor?

I am looking through the PhantomJS source code and I've encountered this line:
Q_PROPERTY(QString frameName READ frameName)
I don't understand how this is correct syntax, it's even missing a semi-colon.
Here is the fine in question on the Github repo, in case you need to sift through it https://github.com/ariya/phantomjs/blob/master/src/webpage.h
It's a macro that the Qt Library defines to have its own Property System. It uses its own macros mainly because of being platform independent (its aim is not to rely on specific compilers/os). I don't think I can add anything not in their reference docs.

Netbeans: C/C++ file-template variables documentation needed

I'm looking for a faq or overview on C/C++ template-file variables in Netbeans (7.0).
(Not to be confused with the template technique). Those you see under Tools > Templates > C++ templates.
e.g.
%<%CLASSNAME%>% %<%DEFAULT_HEADER_EXT%>% %<%DATE%>%
which are automatically filled when you create a new cpp/header file out of that file-template.
The help for the Java template-variables with Freemarker is very extensive, but I found nothing for the C++ equivalent.
When I did a search on CLASSNAME DEFAULT_HEADER_EXT, google gave me 5 results... which were not helpful. So if there is a reference or api, it seems to be hidden somewhere... Not even the netbeans site had any information about that.
And if there is nothing, maybe someone can at least tell me if there is a way to format the %DATE% variable (like this in Java's Freemarker format: ${date?date?string("yyyy")} ).
Still no luck... can't believe that such a feature is not documented... Any help would be appreciated :)
Thanks
I know it's an old question but just stumbled on it and think it's good to have it mentioned:
The documentation of all predefined template variables including the date formatting may be found here: http://wiki.netbeans.org/FaqTemplateVariables

funny looking comments - c++

when i read through source files of opensource projects i often come across some weird phrases in the comments
/*
#brief ......
#usage.....
#remarks....
#par....
*/
questions
1.What are they?(were not mentioned when i was learning c++)
2.Do they have any documentation(where)
They are just comments and as such have no special meaning in C++. They are probably to allow a documentation generator (For example Doxygen) to extract the data from the comments.
Those are for some flavour of automatic documentation generator. Another program runs through the code looking for comments of like you see there. The #... keywords identify how the documentation should be laid out, and that program generates pretty HTML or printed documentation directly from the source code. It's a way to keep the docs up-to-date with the code more easily.