jsduck 5.3 create PHP-Doc - jsduck

Today i tried out the jsDuck 5.3 with my ExtJS project. It works really good. But I've also commented every method and class in PHP.
I've seen that JSDuck 3.11.2 can create a perfekt online documentation from PHP Files, but JSDuck 5.3 doesn't do. Is it possible to load a modul or plugin to the JSDuck 5.3 ?? Or is there an other practice to get a php-doc by jsDuck 5.3 ?

The reason why it 3.x happened to work with PHP was that JSDuck used a bunch of simple regexes to parse the code following a doc-comment, if it encountered code it didn't understand, it just ignored it. So the reason you were able to parse PHP was an accident of poor implementation.
New JSDuck uses an actual JavaScript parser, which fails when you try to feed it something other than JavaScript.
One hackish way to make it work with PHP would be to use some pre-processor on your PHP code which strips away all the code and only leaves doc-comments - this code will then be valid JavaScipt and JSDuck would parse it.
Another option is to open up the internals of JSDuck and add a PHP parser to it.

Related

Is it possible to convert c++ written gnuradio flowgraph to .grc format?

I am trying to understand how does gnss-sdr repo works. It is written in C++ and based on gnuradio. Since the code is pretty complicated for me, I would like to see the flowgraph visualized in GNU Radio Companion as .grc file
I am really stuck at this point. Any help is appreciated.
It is possible to convert a C++-written GNU Radio flowgraph to a .grc file, but it would likely require some manual steps. One approach is to use the GNU Radio Companion (GRC) to create a new flowgraph, and then copy and paste the blocks and connections from the C++ code into the GRC flowgraph. Another approach is to use the grcc command-line tool, which can convert C++ code into a GRC file. However, this tool may not work for all C++ flowgraphs, and may require some modification of the code to be compatible.

How to parse HTML with C++/Qt?

How can i parse the following HTML
<body>
<span style="font-size:11px">12345</span>
<a>Hello<a>
</body>
I would like to retrive the data "12345" from a "span" with style="font-size:11px" from www.testtest.com, but I only want the that very data, and nothing else.
How can I accomplish this?
I think QXmlQuery is what you want.
I think the code will be like
QXmlQuery query;
query.setQuery(html, QUrl("/body/span[#style='font-size:11p']"));
QString r;
query.evaluateTo(&r);
You can also provide URL directly to the query
query.setQuery(QUrl("http://WWW.testtest.com"), QUrl("/body/span[#style='font-size:11p']"));
EDIT: From the Qt 5.6 release blog post:
With 5.6, Qt WebKit and Qt Quick 1 will no longer be supported and are dropped from the release. The source code for these modules will still be available.
So, as of Qt 5.6 – unless you're willing to compile the sources –, QtWebKit is no longer available. If you're using a Qt release older than 5.6 ot are willing to compile QtWebKit, this might be helpful; otherwise this answer is no longer valid.
It is hard to tell you exactly what needs to be done as your explanation is incomplete about the use case. However, there are two ways of proceeding.
QtWebKit
If you already need any other functionality from that module, this is not going to introduce any further dependencies, and it will be the most convenient for you to use.
You need to get the https://doc.qt.io/archives/qt-5.5/qwebelement.html
That will come once you find the first "span" element in your html:
https://doc.qt.io/archives/qt-5.5/qwebframe.html#findFirstElement
Then, you can simply get the text for that element with the corresponding QWebElement method(s). For instances, you can use this one for getting an attribute value:
https://doc.qt.io/archives/qt-5.5/qwebelement.html#attribute
... but you can also request the attribute names as you can see in the documentation, etc.
This is how you will get the 12345 value:
https://doc.qt.io/archives/qt-5.5/qwebelement.html#toPlainText
XML parser in QtCore
If you do not need webkit for your sotware, and the html data comes in a different way rather than directly from the web for which you would need to use QWebKit, then you are better off using the xml parser available in QtCore. It still might be the case even if you do not have any other dependency from QtWebKit that this additional dependency will not cause any issues in your use case. It is hard to tell based upon your description. For sure, this would be less convenient, albeit not that much, compared to the webkit based solution as that is designed for html.
What you need to avoid is QtXmlPatterns. It is an unmaintained software as of now, and that would introduce an additional dependency for your code either way.

Building a Native Client app from nothing

What does it take to build a Native Client app from scratch? I have looked into the documentation, and fiddled with several apps, however, I am now moving onto making my own app and I don't see anything related to creating the foundation of a native client app.
Depending on the version of the SDK you want to use, you have a couple of options.
Pepper 16 and 17: use init_project.py or use an example as a starting point
If you are using pepper_16 or pepper_17, you will find a Python script init_project.py in the project_templates in the SDK. It will setup up a complete set of files (.cc, .html, .nmf) with comments indicating where you need to add code. Run python init_project.py -h to see what options it accepts. Additional documentation can be found at https://developers.google.com/native-client/pepper17/devguide/tutorial.
Pepper 18 and newer: use an example as the starting point
If you are using pepper_18 or newer, init_project.py is no longer included. Instead you can copy a very small example from the examples directory (e.g., hello_world_glibc or hello_world_newlib for C or hello_world_interactive for C++) and use that as a starting point.
Writing completely from scratch
If you want to write your app completely from scratch, first ensure that the SDK is working by compiling and running a few of the examples. Then a good next step is to look at the classes pp::Module and pp:Instance, which your app will need to implement.
On the HTML side, write a simple page with the EMBED element for the Native Client module. Then add the JavaScript event handlers for loadstart, progress, error, abort, load, loadend, and message and have the handlers write the event data to, e.g., the JavaScript console, so that it's possible to tell what went wrong if the Native Client module didn't load. The load_progress example shows how to do this.
Next, create the manifest file (.nmf). From pepper_18 and onwards you can use the generate_nmf.py script found in the tools/ directory for this. If you want to write it from scratch, the examples provide examples both for using newlib and glibc (the two Standard C librares currently supported). See hello_world_newlib/ and hello_world_glibc/, respectively.
If you haven't used a gcc-family compiler before, it is also a good idea to look at the Makefile for some of the examples to see what compiler and linker flags to use. Compiling both for 32-bit and 64-bit right from the beginning is recommended.
Easiest way is to follow the quick start doc at https://developers.google.com/native-client/pepper18/quick-start, in particular steps 5-7 of the tutorial ( https://developers.google.com/native-client/pepper18/devguide/tutorial ) which seems to be what you are asking about.

How to use V8's built in functions

I'm new in both javascript and V8. According to Google's Embedder's Guide, I saw something in the context section talking about built-in utility javascript functions. And I also found some .js files(e.g. math.js) in the downloaded source code, so I tried to write a simple program to call functions in these files, but I failed.
Does a context created by Persistent<Context> context = Context::New() have any built-in js functions? How can I access them?
Is there a way to first import existing js files as a library(something like src="xxx" type="text/javascript" in HTML page) and then run my own execute script?
Can I call google maps api through the embedded V8 library in app? How?
3. Google Maps needs a full browser DOM (or at least XMLHttpRequest I guess), you can't use it from just a Javascript library.
I think v8 gives you the Math.* functions for free.
You need to implement everything else yourself though, like loading other javascript files. shell.cc has some of the functions you might be looking for.
As for the maps API, I believe you would need a full blown rendering engine/javascript engine combo for that. You might be better off taking a look at Webkit or something that you can use to embed Webkit for what you're looking to do, I can't really say.
You can use for example the --allow_natives_syntax or --expose_natives_as option.
Here are examples with MathLog picked at random in src/math.js:
First compile a shell with
$ scons d8 -j8
Then use --expose_natives_as:
$ ./d8 --expose_natives_as nat
V8 version 3.12.7 (candidate) [console: dumb]
d8> nat.MathLog(100)
4.605170185988092
or use --allow_natives_syntax with the '%' prefix:
$ ./d8 --allow_natives_syntax
V8 version 3.12.7 (candidate) [console: dumb]
d8> %MathLog(100)
4.605170185988092

Apache mod_c++ wanted?

I want to experiment a bit with C++ as a server side language. I'm not looking for a framework, and simply want to achieve a silly old "Hello World" webapp using C++.
Is there an Apache HTTP server module that I can install?
If i can do the PHP equivalent of :
<?php
$personName = "Peter Pan";
echo "Hello " . $personName;
I'd be most thrilled! Thanks in advance!
cgi would do this. Just have your C++ app spit its output to stdout and your mod_cgi will handle it
You might want to have a look at http://www.webtoolkit.eu/wt or www.tntnet.org instead.
"mod_c++" doesn't make sense; Once you're talking about compiled programs, Apache doesn't care what language the binary comes from. mod_cgi allows Apache to invoke such a binary (regardless of it's source language) in response to HTTP requests. Read more here:
http://library.thinkquest.org/16728/content/cgi/cplusplus.html
Suppose for the moment the OP wanted something that was "like mod_php, mod_perl". Given the right configuration, it would be monumentally easy for the "mod_c++" to look at the source files, and compiled files and decide whether it had to do a "one off" compilation task. In fact this is how make works.
I know the OP probably didn't mean that it had to be "interpreted", but it's certainly not impossible to allow apache to compile cpp files on the fly if needed [this is how jsp works, btw].
I did create a mod_cpp once. It basically was written in c, but loaded a .so which was in turn written in C++.
Its performance was really good, but lacked a lot of things that we take for granted in things like PHP (sessions, HTML un/escaping, etc). It did use a template engine to separate the HTML from the C++.
I tell you, the initial set-up was a lot of work (the mod_cpp part); after that, it was kinda easy to write the .so's. I even tried to create an sf.net project to open-source it, but I never got around to actually porting it :-(
In summary: I did not find anything like that on the net, did it myself and found out to be a lot more work then I anticipated, but the result was very cool! This helped me a lot: Apache Modules
I'm not saying there is no such thing, but if there is it would be monumentally inefficient. C++ is a compiled language, not an interpretive one, so the putative Apache C++ module would have to invoke the C++ compiler to compile the code before executing it. This would be very, very slow, apart from other problems.