Atomのパッケージを作る(6)実装編

実装する

markdown-tocが便利なのだが、更新が滞っているみたいなので、新機能の追加、バグを修正して、新しくmarkdown-toc-plusとして実装してみた。

マークダウンファイルのヘッダー(#)をtable of contentsとしてまとめあげてくれます。

CHANGELOG.mdを見てもらうと変更点がわかりやすい。

## markdown-toc-plus v0.1.2
* Insert a line after TOC so that "<!-- /TOC --> " correctly works

## markdown-toc-plus v0.1.0
* add a new feature to manage depth (depthTo, depthFrom)

## markdown-toc-plus v0.0.1
* Fork from markdown-toc(https://github.com/nok/markdown-toc)

## markdown-toc v0.2.3
* Adapt Atom 1.0.0 API
* Add ordered list feature by https://github.com/spjoe

specsを書いてみる

コマンドが正しく動くかぐらいしかテストできてないので、追加していく予定。というかあまり深くは理解していないのでspecsのプルリクエストがあると嬉しい。
spec/markdown-toc-plus-spec.coffee

describe "the markdown-toc-plus", ->
  [workspaceElement] = []

  beforeEach ->
    workspaceElement = atom.views.getView(atom.workspace)

    waitsForPromise ->
      atom.workspace.open('test.md')


  describe "when the markdown-toc-plus is toggled", ->
    it "is ready for creating a table of contents", ->
      runs -> atom.commands.dispatch workspaceElement, 'markdown-toc-plus:toggle'

      editor = atom.workspace.getActiveTextEditor()
      expect(editor.getPath()).toContain 'test.md'

...

公開する

公開の手順、アップデートの手順はこちら

markdown-toc-plus-spec
README.mdにgifつけると面白そうなのであとでやっておこう。

*追記:
GifGrabberを使ってgifを作ってみたが何やってるか全然わからん笑
f:id:uraway:20151216144612g:plain

**さらに追記:
Themeを白くするとこうなった