@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
160 lines (119 loc) • 9.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const shell_1 = require("../r-bridge/shell");
const log_1 = require("../../test/functionality/_helper/log");
const tree_sitter_executor_1 = require("../r-bridge/lang-4.x/tree-sitter/tree-sitter-executor");
const doc_files_1 = require("./doc-util/doc-files");
const doc_code_1 = require("./doc-util/doc-code");
const doc_cli_option_1 = require("./doc-util/doc-cli-option");
const doc_benchmarks_1 = require("./doc-util/doc-benchmarks");
const numbers_1 = require("../util/numbers");
const html_hover_over_1 = require("../util/html-hover-over");
const doc_structure_1 = require("./doc-util/doc-structure");
const doc_repl_1 = require("./doc-util/doc-repl");
const doc_auto_gen_1 = require("./doc-util/doc-auto-gen");
const doc_general_1 = require("./doc-util/doc-general");
const doc_dfg_1 = require("./doc-util/doc-dfg");
async function getText(shell) {
const dateOptions = { year: 'numeric', month: 'short', day: 'numeric' };
return `
[](${doc_files_1.FlowrGithubBaseRef}/flowr/wiki)\\
[](${doc_files_1.FlowrGithubBaseRef}/flowr/actions/workflows/qa.yaml)
[](https://codecov.io/gh/flowr-analysis/flowr)
[](${doc_files_1.FlowrDockerRef})
[](${doc_files_1.FlowrGithubBaseRef}/flowr/releases/latest)
[](${doc_files_1.FlowrVsCode})
[](https://zenodo.org/doi/10.5281/zenodo.13319290)
_flowR_ is a sophisticated, static [dataflow analyzer](https://en.wikipedia.org/wiki/Data-flow_analysis) for the [R programming language](https://www.r-project.org/).
It offers a wide variety of features, for example:
* 🍕 **program slicing**\\
Given a point of interest like the visualization of a plot, _flowR_ reduces the program to just the parts which are relevant
for the computation of the point of interest.
${(0, doc_general_1.prefixLines)((0, doc_structure_1.details)('Example: Slicing with flowR', `
The simplest way to retrieve slices is with flowR's [Visual Studio Code extension](${doc_files_1.FlowrVsCode}).
However, you can slice using the [REPL](${doc_files_1.FlowrWikiBaseRef}/Interface#using-the-repl) as well.
This can help you if you want to reuse specific parts of an existing analysis within another context or if you want to understand
what is happening in the code.
For this, let's have a look at the example file, located at ${(0, doc_files_1.linkFlowRSourceFile)('test/testfiles/example.R')}:
${(0, doc_code_1.codeBlock)('r', (0, doc_files_1.getFileContentFromRoot)('test/testfiles/example.R'))}
Let's suppose we are interested only in the \`sum\` which is printed in line 11.
To get a slice for this, you can use the following command:
${await (0, doc_repl_1.documentReplSession)(shell, [{
command: ':slicer test/testfiles/example.R --criterion "11@sum"',
description: ''
}])}
`), ' ')}
* 📚 **dependency analysis**\\
Given your analysis project, flowR offers a plethora of so-called [queries](${doc_files_1.FlowrWikiBaseRef}/Query-API) to get more information about your code.
An important query is the [dependencies query](${doc_files_1.FlowrWikiBaseRef}/Query-API#dependencies-query), which shows you the library your project needs,
the data files it reads, the scripts it sources, and the data it outputs.
${(0, doc_general_1.prefixLines)((0, doc_structure_1.details)('Example: Dependency Analysis with flowR', `
The following showcases the dependency view of the [Visual Studio Code extension](${doc_files_1.FlowrVsCode}):

`), ' ')}
* 🚀 **fast data- and control-flow graphs**\\
Within just ${'<i>' + (0, html_hover_over_1.textWithTooltip)((0, numbers_1.roundToDecimals)(await (0, doc_benchmarks_1.getLatestDfAnalysisTime)('"social-science" Benchmark Suite (tree-sitter)'), 1) + ' ms', 'This measurement is automatically fetched from the latest benchmark!') + '</i>'} (as of ${new Date(await (0, doc_benchmarks_1.getLastBenchmarkUpdate)()).toLocaleDateString('en-US', dateOptions)}),
_flowR_ can analyze the data- and control-flow of the average real-world R script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
and consult the [wiki pages](${doc_files_1.FlowrWikiBaseRef}/Dataflow-Graph) for more details on the dataflow graph.
${(0, doc_general_1.prefixLines)((0, doc_structure_1.details)('Example: Generating a dataflow graph with flowR', `
You can investigate flowR's analyses using the [REPL](${doc_files_1.FlowrWikiBaseRef}/Interface#using-the-repl).
Commands like ${(0, doc_cli_option_1.getReplCommand)('dataflow*')} allow you to view a dataflow graph for a given R script.
Let's have a look at the following example:
${(0, doc_code_1.codeBlock)('r', (0, doc_files_1.getFileContentFromRoot)('test/testfiles/example.R'))}
To get the dataflow graph for this script, you can use the following command:
${await (0, doc_repl_1.documentReplSession)(shell, [{
command: ':dataflow* test/testfiles/example.R',
description: `
Following the link output should show the following:
${await (0, doc_dfg_1.printDfGraphForCode)(shell, (0, doc_files_1.getFileContentFromRoot)('test/testfiles/example.R'), { showCode: false })}`
}])}
`), ' ')}
If you want to use flowR and the features it provides, feel free to check out the:
- [Visual Studio Code extension](${doc_files_1.FlowrVsCode}): provides access to flowR directly in VS Code (or [vscode.dev](https://vscode.dev/))
- [RStudio Addin](${doc_files_1.FlowrGithubBaseRef}/rstudio-addin-flowr): integrates flowR into [RStudio](https://posit.co/downloads/)
- [R package](${doc_files_1.FlowrGithubBaseRef}/flowr-r-adapter): use flowR in your R scripts
- [Docker image](${doc_files_1.FlowrDockerRef}): run flowR in a container, this also includes [flowR's server](${doc_files_1.FlowrWikiBaseRef}/Interface#communicating-with-the-server)
- [NPM package](${doc_files_1.FlowrNpmRef}): include flowR in your TypeScript and JavaScript projects
## ⭐ Getting Started
To get started with _flowR_ and its features, please check out the [Overview](${doc_files_1.FlowrGithubBaseRef}/flowr/wiki/Overview) wiki page.
The [Setup](${doc_files_1.FlowrGithubBaseRef}/flowr/wiki/Setup) wiki page explains how you can download and setup _flowR_ on your system.
With docker 🐳️, the following line should be enough (and drop you directly into the read-eval-print loop):
${(0, doc_code_1.codeBlock)('shell', 'docker run -it --rm eagleoutice/flowr')}
You can enter ${(0, doc_cli_option_1.getReplCommand)('help')} to gain more information on its capabilities.
<details>
<summary>Example REPL session</summary>

</details>
## 📜 More Information
For more details on how to use _flowR_ please refer to the [wiki pages](${doc_files_1.FlowrGithubBaseRef}/flowr/wiki),
as well as the deployed [code documentation](https://flowr-analysis.github.io/flowr/doc/).
## 🚀 Contributing
We welcome every contribution! Please check out the [contributing guidelines](${doc_files_1.FlowrGithubBaseRef}/flowr/tree/main/.github/CONTRIBUTING.md) for more information.
### Contributors
<a href="https://github.com/flowr-analysis/flowr/graphs/contributors">
<img src="https://contrib.rocks/image?repo=flowr-analysis/flowr" alt="flowR Contributors"/>
</a>
----
*flowr* is actively developed by [Florian Sihler](https://eagleoutice.github.io/portfolio/) under the
[GPLv3 License](LICENSE).\\
It is partially supported by the German Research Foundation (DFG) under the grant [504226141](https://gepris.dfg.de/gepris/projekt/504226141) ("CodeInspector").
----
### Generation Notice
Please notice that this file was generated automatically using the file ${(0, doc_auto_gen_1.fileNameForGenHeader)(module.filename)} as a source.\\
If you want to make changes please edit the source file (the CI will take care of the rest).
In fact, many files in the [wiki](${doc_files_1.FlowrWikiBaseRef}) are generated, so make sure to check for the source file if you want to make changes.
`.trim();
}
/** if we run this script, we want a Markdown representation of the capabilities */
if (require.main === module) {
void tree_sitter_executor_1.TreeSitterExecutor.initTreeSitter().then(() => {
(0, log_1.setMinLevelOfAllLogs)(6 /* LogLevel.Fatal */);
const shell = new shell_1.RShell();
void getText(shell).then(str => {
console.log(str);
}).finally(() => {
shell.close();
});
});
}
//# sourceMappingURL=print-readme.js.map