Code Monkey home page Code Monkey logo

api-blueprint-sublime-plugin's Introduction

API Blueprint Sublime Text Plugin

This is the official API Blueprint plugin for Sublime Text with following features:

  • Syntax highlighting for the API Blueprint format
  • Compiling blueprint into its AST media-type
  • Live linting of blueprints as you type using SublimeLinter3

This plug-in works both with Sublime Text 2 and 3. However linting is supported on Sublime Text 3 only.

Requirements

Drafter

In order for this plugin to work properly you need to have the API Blueprint command line tool drafter installed.

To install Drafter on OS X using run the following command:

$ brew install drafter

Refer to Drafter installation notes for details on installing on OS X & Linux or Windows.

SublimeLinter3 (optional)

This plugin offers linting of your blueprints using the SublimeLinter3 plugin framework. In order for linting to work please install SublimeLinter3.

Markdown Highlighting (optional)

Note the API Blueprint Sublime Text syntax support relies on Markdown highlighing support in the color scheme used. For best results use a color scheme that supports Markdown-specific scopes (e.g. markdown: heading) such as Monokai extended, and install Sublime Markdown Extended.

Installation

Using Package Control

With Package Control:

  1. Run “Package Control: Install Package” command, find and install API Blueprint plugin.
  2. Restart SublimeText editor (if required)

From the Source

With Drafter installed run the following command in your Sublime Text 3 packages directory:

$ git clone https://github.com/apiaryio/api-blueprint-sublime-plugin.git  "API Blueprint"

Depending on your OS (and Sublime Text version) the packages directories are:

  • Linux: ~/.config/sublime-text-3/packages
  • OS X: ~/Library/Application\ Support/Sublime\ Text\ 3/Packages
  • Windows: %APPDATA%\Sublime Text 3\Packages

Using the Plugin

Commands

You can access the commands either using the command palette (CTRL+SHIFT+P or CMD+SHIFT+P) or via shortcuts.

Shortcuts

  • ALT+SHIFT+B: Parse the active file and open result AST including any possible parser messages in a new tab.

Acknowledgements

License

MIT License. See the LICENSE file.

api-blueprint-sublime-plugin's People

Contributors

bsutherland avatar danielgtaylor avatar jackub avatar klokane avatar kylef avatar mkj-is avatar neonichu avatar phpdude avatar pksunkara avatar wmeldon avatar zdne 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-blueprint-sublime-plugin's Issues

Windows : 'str' does not support the buffer interface

Hello,

I've tried using this plugin without success on Windows 7x64 with Sublime 3. I've found a working solution but first, here's the traceback:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 543, in run_
    return self.run(edit, **args)
  File "C:\Users\Gabriel\AppData\Roaming\Sublime Text 3\Packages\API Blueprint\APIBlueprint.py", line 85, in run
    result = run_command ("snowcrash", args=args, source=source)
  File "C:\Users\Gabriel\AppData\Roaming\Sublime Text 3\Packages\API Blueprint\APIBlueprint.py", line 39, in run_command
    stat = proc.communicate(input=source)
  File "X/subprocess.py", line 906, in communicate
  File "X/subprocess.py", line 1180, in _communicate
TypeError: 'str' does not support the buffer interface

This error is very common and related to Python string encoding.

My solution was to completely remove win32 code in APIBlueprint.py in def run_command() and then it worked:

def run_command(cmd, args = [], source="", cwd = None, env = None):
  settings = sublime.load_settings('APIBlueprint.sublime-settings')

  if not type(args) is list:
    args = [args]

  #if sys.platform == "win32":
    #proc = Popen([cmd]+args, env=env, cwd=cwd, stdout=PIPE, stdin=PIPE, stderr=PIPE, shell=True)
    #stat = proc.communicate(input=source)

  #else:
  if env is None:
    env = {"PATH": settings.get('binDir', '/usr/local/bin')}

    command = [cmd] + args

    proc = Popen(command, env=env, cwd=cwd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    stat = proc.communicate(input=source.encode('utf-8'))

  okay = proc.returncode == 0

  #remove leading empty line
  lines = stat[1].decode('UTF-8').split('\n')
  if not lines[0]:
    lines.pop(0)
  sanitized_errout = '\n'.join(lines)

  return {"okay": okay, "out": stat[0].decode('UTF-8'), "err": sanitized_errout}

plugin does not work

I have markdown extended installed, snowcrash installed, monokai extended install, but still the only thing this plugin highlits is "HOST".

Here's the screenshot
2014-08-16 0 36 12

No highlighting in blueprint code

Hello -

I really like apiaryio & sublime, so I would love to combine both :)

Unfortunately, the syntax highlighting does not work for me:

  • sublime text2
  • fresh install of snowcrash, generation of AST works fine
  • only highlights are the resource names (the User bit from [User][] is shown in yellow

Any ideas on how to get more highlighting and/or description of what I could expect?

Thanks in advance!

put the plugin into package control

I can maybe look into this as it'll be rather Python thing and I'm annoyed by the fact I can't install it instantly from the editor (or find it! previously I did not know it exists, because it wasn't showing up in search...).

Linting doesn't recognise comments

The docs for API Blueprint suggest comments should be HTML style:

<!-- This is a comment -->

but the linter highlights it as an unrecognised block.

example of using resulting ast

i've just installed the plugin and it's not clear to me as to how to use the ast file resulting from the parse command. specifically, i see the following warnings:

warning: (3)  unable to parse additional parameter traits, expected '([required | optional], [<type>], [`<example value>`])', e.g. '(optional, string, `Hello World`)' :21574:234
warning: (6)  empty response message-body :25880:13

while the error text is simple enough to understand, it's not clear where i'm looking for each one. it would be helpful then to provide some explanation of the warnings/errors and provide an example error/explanation in the read me.

Folding markers are not correct

It seems like current code folding markers are just the one inherited from Markdown. We could improve this one a lot on Resource Groups, Groups and so on.

Installation instructions

I've followed all installation steps and installed all plugins successfully. However, autocomplete and highlighting doesn't seem to work. I can still parse the file and open result AST though.

screen shot 2015-08-25 at 1 42 13 pm

I'm not a Sublime user. Am I missing any settings or configuration assumed in the installation instructions?

EDIT:
I've got some coloring selecting:
Preferences > Color Scheme > Monokai Extended > Monokai Extended

screen shot 2015-08-25 at 1 52 19 pm

However, no autocompletion yet...

Don't understand the result

after execute Ctrl + Shft + b
it opens a new tab: anf this is shown:

OK.

_version: 1.0
metadata:
HOST:
value: "http://..../"
name: "..."
description: "..."
resourceGroups:

.....

But I don't understand this output, I don't see any, no prview :(

Incorrect highlighting of escaped strings in MSON

screen shot 2015-05-13 at 17 18 41

As seen in the screenshot, both date strings should be completely rendered in the same color.

The MSON being used:

- sys
    - type: Space
    - id: cfexampleapi
    - version: 3 (number)
    - createdBy
        - sys
            - type: Link
            - linkType: User
            - id: 7BslKh9TdKGOK41VmLDjFZ
    - createdAt: `2013-06-23T19:02:00Z`
    - updatedBy
        - sys
            - type: Link
            - linkType: User
            - id: 7BslKh9TdKGOK41VmLDjFZ
    - updatedAt: `2014-07-09T07:18:20Z`
- name: Contentful Example API

Code blocks within list items should be code-blocks

Code-blocks within list items (i-e, blocks that are indented by 4 spaces inside a list item) are not marked as code blocks, so underscores and other markdown syntax still work and cause the code not to be rendered correctly.

Example

+ Model (application/json)

        {
            "_id": "963bc95f1c1a56f69f3392b4aa03302f",
            "foo": "_bar"
        }

screen shot 2015-09-21 at 22 10 15

Moved from apiaryio/api-blueprint#241

Schema body is not highlighted

This plugin does not highlight the schema body. If you replace Schema with Body, the highlighting comes back.

I had a look at the source and can't seem to figure out why (my sublime plugin skills are not great though).

Highlighting broken

I'm using Mac.

  1. Installed the plugin using Package Control.
  2. Opened arbitrary apiary.apib file.
  3. Selected "API Blueprint" highlighting.
  4. Text is still not highlighted. Here and there, one or two words get some color, but the coloring does not make much sense or seem to be very helpful. Nothing from Markdown gets highlighted.

screen shot 2015-09-08 at 13 14 34

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.