Coder Social home page Coder Social logo

vrurg / perl6-corehackers-sourcery Goto Github PK

View Code? Open in Web Editor NEW

This project forked from raku-community-modules/corehackers-sourcery

0.0 2.0 0.0 24 KB

Perl 6 module: show source locations of core methods and subs

License: Artistic License 2.0

Perl 6 100.00%

perl6-corehackers-sourcery's Introduction

Build Status

NAME

CoreHackers::Sourcery - Show source locations of core methods and subs

SYNOPSIS

    use CoreHackers::Sourcery;
    &say.sourcery("foo").put;

    # OUTPUT:
    # src/core/io_operators.pm:22 https://github.com/rakudo/rakudo/blob/c843682/src/core/io_operators.pm#L22

    put sourcery Int, 'abs';         # method called on a type object
    put sourcery 42,  'split';       # method called on an Int object
    put sourcery 42,  'base', \(16); # method call with args

DESCRIPTION


Update: as of Rakudo v2016.10.286.g.2.e.9.e.89.b, the .line and .file reported by the methods indicate original files, making this module less useful... but still working.


When calling .line or .file on core Code objects, you get a line in the setting. The setting is a giant file, so such information is not ideal when trying to locate the place to edit the code.

This module provides the actual location of the sub or method definition in Rakudo's source code.

BLOG POST

Related blog post: http://perl6.party/post/Perl-6-Core-Hacking-Wheres-Da-Sauce-Boss

METHODS

.sourcery

    &say.sourcery.put;        # location of the `proto`
    &say.sourcery('foo').put; # location of the candidate that can do 'foo'

The core Code class and its core subclasses get augmented with .sourcery method. Calling this method with no arguments provides the location of the method or sub, or the proto of the multi.

When called with arguments, returns the location of the narrowest candidate, possibly dieing if no candidate can be found.

Returns a list of two strings: the file:line-number referring to the core file and the GitHub URL.

SUBROUTINES

sourcery

    put sourcery &say;              # just Code object
    put sourcery &say, \('foo');    # find best candidate for a Code object
    put sourcery Int, 'abs';        # method `abs` on a type object

    # find best candidate for method `base` on object 42, with argument `16`
    put sourcery 42, 'base', \(16);

Operates similar to the method form, except allows more flexibility, such as passing object/method names. Returns a list of two strings: the file:line-number referring to the core file and the GitHub URL.

ENVIRONMENTAL VARIABLES

SOURCERY_SETTING

The location of the setting file. Defaults to:

    $*EXECUTABLE.parent.parent.parent.child(&say.file)

This will generally work for most installs.


REPOSITORY

Fork this module on GitHub: https://github.com/zoffixznet/perl6-CoreHackers-Sourcery

BUGS

To report bugs or request features, please use https://github.com/zoffixznet/perl6-CoreHackers-Sourcery/issues

AUTHOR

Zoffix Znet (http://zoffix.com/)

LICENSE

You can use and distribute this module under the terms of the The Artistic License 2.0. See the LICENSE file included in this distribution for complete details.

The META6.json file of this distribution may be distributed and modified without restrictions or attribution.

perl6-corehackers-sourcery's People

Contributors

zoffixznet avatar vrurg avatar alexdaniel avatar cuonglm avatar samcv avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.