Skip to content

Commit

Permalink
Make the codebase prettier.
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-r-rose committed Jul 11, 2018
1 parent 87abf73 commit 1054843
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 85 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
**/lib
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ to the heading in question.

Here is an animation showing the extension's use, with a notebook from the
[Python Data Science Handbook](https://github.com/jakevdp/PythonDataScienceHandbook):
![Table of Contents](toc.gif "Table of Contents")

![Table of Contents](toc.gif 'Table of Contents')

## Prerequisites

* JupyterLab v0.33
- JupyterLab v0.33

## Installation

Expand All @@ -32,13 +31,17 @@ jupyter labextension install .

You can then run JupyterLab in watch mode to automatically pick up changes to `@jupyterlab/toc`.
Open a terminal in the `@jupyterlab/toc` repository directory and enter

```bash
jlpm run watch
```

Then launch JupyterLab using

```bash
jupyter lab --watch
```

This will automatically recompile `@jupyterlab/toc` upon changes,
and JupyterLab will rebuild itself. You should then be able to refresh the
page and see your changes.
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"scripts": {
"build": "tsc",
"clean": "rimraf lib",
"precommit": "lint-staged",
"prettier": "prettier --write '**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}'",
"watch": "tsc -w"
},
"dependencies": {
Expand All @@ -49,12 +51,24 @@
"devDependencies": {
"@types/react": "~16.0.19",
"@types/react-dom": "~16.0.5",
"husky": "^0.14.3",
"lint-staged": "^7.2.0",
"prettier": "^1.13.7",
"rimraf": "^2.6.1",
"tslint": "^5.10.0",
"tslint-config-prettier": "^1.13.0",
"tslint-plugin-prettier": "^1.3.0",
"typescript": "~2.9.2"
},
"resolutions": {
"@types/react": "~16.0.19"
},
"lint-staged": {
"**/*{.ts,.tsx,.css,.json,.md}": [
"prettier --write",
"git add"
]
},
"jupyterlab": {
"extension": "lib/extension.js"
}
Expand Down
30 changes: 15 additions & 15 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ import {
ILayoutRestorer,
IMimeDocumentTracker,
JupyterLab,
JupyterLabPlugin,
JupyterLabPlugin
} from '@jupyterlab/application';

import {IDocumentManager} from '@jupyterlab/docmanager';
import { IDocumentManager } from '@jupyterlab/docmanager';

import {IEditorTracker} from '@jupyterlab/fileeditor';
import { IEditorTracker } from '@jupyterlab/fileeditor';

import {INotebookTracker} from '@jupyterlab/notebook';
import { INotebookTracker } from '@jupyterlab/notebook';

import {IRenderMimeRegistry} from '@jupyterlab/rendermime';
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';

import {TableOfContents} from './toc';
import { TableOfContents } from './toc';

import {
createLatexGenerator,
createNotebookGenerator,
createMarkdownGenerator,
createRenderedMarkdownGenerator,
createRenderedMarkdownGenerator
} from './generators';

import {ITableOfContentsRegistry, TableOfContentsRegistry} from './registry';
import { ITableOfContentsRegistry, TableOfContentsRegistry } from './registry';

import '../style/index.css';

Expand All @@ -42,9 +42,9 @@ const extension: JupyterLabPlugin<ITableOfContentsRegistry> = {
ILayoutRestorer,
IMimeDocumentTracker,
INotebookTracker,
IRenderMimeRegistry,
IRenderMimeRegistry
],
activate: activateTOC,
activate: activateTOC
};

/**
Expand All @@ -57,26 +57,26 @@ function activateTOC(
restorer: ILayoutRestorer,
mimeDocumentTracker: IMimeDocumentTracker,
notebookTracker: INotebookTracker,
rendermime: IRenderMimeRegistry,
rendermime: IRenderMimeRegistry
): ITableOfContentsRegistry {
// Create the ToC widget.
const toc = new TableOfContents({docmanager, rendermime});
const toc = new TableOfContents({ docmanager, rendermime });

// Create the ToC registry.
const registry = new TableOfContentsRegistry();

// Add the ToC to the left area.
toc.title.label = 'Contents';
toc.id = 'table-of-contents';
app.shell.addToLeftArea(toc, {rank: 700});
app.shell.addToLeftArea(toc, { rank: 700 });

// Add the ToC widget to the application restorer.
restorer.add(toc, 'juputerlab-toc');

// Create a notebook TableOfContentsRegistry.IGenerator
const notebookGenerator = createNotebookGenerator(
notebookTracker,
rendermime.sanitizer,
rendermime.sanitizer
);
registry.addGenerator(notebookGenerator);

Expand Down Expand Up @@ -110,7 +110,7 @@ function activateTOC(
}
return;
}
toc.current = {widget, generator};
toc.current = { widget, generator };
});

return registry;
Expand Down
Loading

0 comments on commit 1054843

Please sign in to comment.