Giter Club home page Giter Club logo

sublime-text-2-goto-documentation's Introduction

GotoDocumentation

A Sublime Text plugin to jump to documentation for the current keyword.

Supports

  • PHP
  • JS / CoffeeScript
  • HTML
  • CSS/SASS/LESS
  • Python (via pydoc)
  • Clojure
  • Go
  • Ruby (+Rails)
  • C / C++
  • Perl
  • C#
  • Lua
  • Postgres
  • Erlang
  • Smarty
  • Haskell
  • ...you can add any other language via settings

Installation

Via Package Control
Search for GotoDocumentation

Manually
Clone this project in your Packages folder under the name GotoDocumentation.
git clone https://github.com/kemayo/sublime-text-2-goto-documentation.git GotoDocumentation

How to use

Move the cursor inside the word you want the docs for and:

  • Press Super+Shift+H or
  • Open command palette (Ctrl+Shift+P) and search for for GotoDocumentation

Edit the urls

GotoDocumentation allows you to edit the url that opens by editing the settings.

The available settings are:

{
    "prefix": "", // added at the begging of the query
    "suffix": "", // added at the end of the query
    "docs": { // obj containing the docs for each scope
              // these are merged with the default ones


        // the key value pair represent scope -> doc url
        // supported placeholders:
        //  - %(query)s the selected text/word
        //  - %(scope)s the current scope
       "css": "http://devdocs.io/#q=%(scope)s+%(query)s",

        // we can also have an object to
        // run a command for finding docs
        // inside the command you can use the same placeholders
        "python": {
            // the command to be executed
            "command": ["python", "-m", "pydoc", "%(query)s"],
            // a regex to determine if this was an invalid response from the console
            "failTest": ".*no Python documentation found for.*",
            // regex to select something from the valid response
            "changeMatch": "(Related help topics)",
            // regex to replace the matched result
            "changeWith": "-------\n\\1",
            // fallback url: if failTest returns true this will be used
            "url": "http://docs.python.org/3/search.html?q=%(query)s"
        }
    },
    // if we have no docs for the current scope
    // we will try using the fallback one,
    // to disable set to false
    "fallback_scope": "google"
}

The change replace is done with the re.sub method

How to get the scope

To get the scope for a specific place open your sublime console with ctrl + ` and paste in this command view.scope_name(view.sel()[0].begin()).rpartition('.')[2].strip()
You can then use that scope to set a rule in the docs dictionary(object).

Contributions

Submit a patch adding more and I'll include it.

If you find a bug or have suggestions open an issue here

sublime-text-2-goto-documentation's People

Contributors

bertbalcaen avatar bilke avatar buhrmi avatar dufferzafar avatar erbridge avatar guillermooo avatar kemayo avatar mihai-vlc avatar rdsoze avatar szensk avatar taebox avatar tkopets avatar unowen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublime-text-2-goto-documentation's Issues

Update the plugin

Hello,
first of all thank you for this plugin it works grate.
However not everybody uses the same docs, and I found myself in the past having to clone and maintain my own version of this plugin witch is fine but I think we can do better.

I made a few changes here: https://github.com/ionutvmi/GotoDocumentation

Basically it allows the end user to use whatever docs he wants (local or remote).
They can do that by keeping a settings file.
I will continue to maintain that version however I don't see the point in having 2 plugins that do the same thing and I would like to merge it with this one to have it available in the package control also.

Because the changes are quite large I haven't made a pull request yet and changed the name of the plugin.

If you like it and you would like to merge it let me know and I will make a pull request.

Documentation for HTML (Rails)

Hi,

Documentation does not works for format HTML(Rails):

scope = text.html.ruby source.ruby.rails.embedded.html
extracted_scope = html

so I've added a condition:
if re.search('rails', scope):
extracted_scope = 'rails'

in 71,72 line and if the scope is from rails then it will send to rails_doc method.

Br,
Grzegorz

Choose which browser to open documentation in?

Morning,

I'm running Linux Mint and just installed this package. I like it a lot. The only thing is that I use chromium as my default browser but the package opens firefox?

It is not immediately apparent to me how to change this, is there a way and I'm just missing it?

GotoDocumentation not working on XP, 8 and Mavericks.

Hi, I've tried to install the plugin using Package Manager or downloading to the Packages folder on Windows XP, Windows 8.1 and OSx Mavericks 10.9.4 but in all OSes using keyboard shortcuts or CMD+SHIFT+P > Goto Documentation (OSx) or CTRL+SHIFT+P > Goto Documentation (Windows) the plugin only opens Google (fallback_scope), I've tried with PHP, CSS and JS files and all extensions opens Google, if I change "fallback_scope" to "php" it always opens php.net.

Only fallback_scope are "working". I think that the problem is with scope detection, If I run on console
view.scope_name(view.sel()[0].begin()).rpartition('.')[2].strip() it detects the right scope.

ERB Files: e.g., link_to => context unknown HTML

Hello,

Love the plugin.

Just trying out the plugin in on an ERB file, and when I press the hot-key on 'link_to' in an ERB file I get teh following error:
This scope is not supported: html.

I see that rails support is listed. Am I doing something wrong?

~S

Support for Ruby (Not Rails)

You have ruby_doc, but it goes to the same place as rails_doc (api.rubyonrails.org). Here's the correct location:

    def ruby_doc(self, keyword, scope):
        open_url(" http://ruby-doc.org/q/%s" % keyword)

ST3 Package

Can't seem to find this package on ST3. Is it only available through manual install?

Not working in Windows

Getting error in Windows.
Can't figure out why.

Traceback (most recent call last):
  File ".\sublime_plugin.py", line 356, in run_
TypeError: run() got an unexpected keyword argument 'url'

"super+shift+h"

Hi,
on OSX I tried any keyboardshortcut like:
"cmd+shift+h"
"ctrl+shift+h"
"alt+shift+h"
but no shortcuts is working ?

Opens in non-default browser

OS: macOS 10.12.5
In spite of the default browser being Chrome, it always opens documentation in Firefox. I think it might be due to a change in python's webbrowser package, or maybe something in macOS. Perhaps the method described in this StackOverflow answer might fix it. You could pass the browser string as a package setting.

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.