Reason Native
  • Docs
  • Help
  • GitHub

โ€บFile Context Printer

Overview

  • Introduction
  • Native Basics
  • Getting Started

Rely

  • Introduction
  • Quickstart
  • Guides

    • Setup and Teardown
    • Mock Functions

    API Reference

    • Basic API
    • Expect
  • Advanced

Console

  • Introduction
  • Quickstart
  • API

Pastel

  • Introduction
  • Quickstart
  • API
  • Console

Refmterr

  • Introduction
  • Quickstart

File Context Printer

  • Introduction
  • Quickstart
  • API

File Context Printer Quickstart

This quickstart builds off Getting Started and assumes you have a native Reason project set up.

Install Pastel

To install File Context Printer in your project with esy, run

esy add @reason-native/file-context-printer

This will add @reason-native/file-context-printer into your package.json.

In order to use File Context Printer, you must add it to your build system. With dune, file-context-printer.lib must be added to the relevant dune file:

(libraries ... file-context-printer.lib)

Sample Code

Start by initializing a File Context Printer module:

module FCP =
  FileContextPrinter.Make({
    let config =
      FileContextPrinter.Config.initialize({linesBefore: 3, linesAfter: 3});
  });

From there, extract and print file context like so:

let start = (
  7, /* start line */
  1 /* start char */
);
let end = (
  7, /* start line */
  11 /* start char */
);
FCP.printFile(
  "src/file-context-printer/test/DummyFile.re",
  (start, end),
)
 4 โ”†  * This source code is licensed under the ...
 5 โ”†  * LICENSE file in the root directory of ...
 6 โ”†  */;
 7 โ”† let myFunction = () => print_endline("do something");
 8 โ”† 
 9 โ”† let ex = (arg) => {
10 โ”†     if(arg === true) {
โ† IntroductionAPI โ†’
  • Install Pastel
  • Sample Code
Reason Native
Projects
RelyConsolePastelRefmterrFile Context Printer
More
GitHubStar
Facebook Open Source
Copyright ยฉ 2021 Facebook Inc.