Fixing chapter content
Pull requests to fix / improve chapter content are welcome! The chapters are written in markdown, and
you can find them under
chapters/. When there's an executable code block, the code for it will be
exercises/. For fixing chapter content, those are the only two directories you should
need to worry about in here.
Requesting new chapters
If there's something you'd like to see in the AllenNLP Guide that's not currently there, we'd love to hear about it! Please look at the currently-open issues for chapter requests. If what you're looking for is listed there, please add an emoji reaction to the issue description, so we know what to prioritize. If you would like a chapter that's not listed there, feel free to open a new issue describing what you're looking for.
Adding a new chapter
If you'd like to contribute a chapter, please let us know in the appropriate github issue (mentioned
above). Once we've given a green light, just open a PR with a new markdown file under the right
chapters/, along with a corresponding entry in
src/outline.js. See below for info on
how to do local development when writing the chapter.
Running the app
To start the local development server, install Gatsby
and then all other dependencies. This should serve up the app on
npm install -g gatsby-cli # Install Gatsby globally npm install # Install dependencies npm run dev # Run the development server
This app uses REVIZ-preferred code formatting. To ensure components are formatted correctly, you can run the following command to check and fixing linting issues before committing changes.
npm run lint:fix
If you're developing on a Mac and wish to test changes on an iPhone, the following command will allow the Gatsby server running locally on your machine to be accessed by any device connected to the same Wi-fi network:
gatsby develop -H $(hostname) -p 8000
Look for the web address and port that the Gatsby server exposes. It should look something like
Unlike most AI2 web apps, package management is handled via NPM instead of Yarn, and the routing and static site generation is driven by Gatsby instead of NextJS. This app also does not use TypeScript, as it was not included in the template that this app was forked from.
package.json for list of all packages used in this app.
All files added to
/static will become available at the root of the deployed
site. For example,
/static/diagram.svg can be referenced in the guide as
Chapters are placed in
/chapters and are Markdown files
<exercise> components. They'll be turned into pages, e.g.
/overview. In their frontmatter block at the top of the file, they need to
type: chapter, as well as the following meta:
--- title: The chapter title description: The chapter description type: chapter # important: this creates a standalone page from the chapter ---
outline.js and Chapter Organization
Chapter navigation is rendered programmatically via
outline.js. Chapters are grouped into "parts," as can be seen in the structure of the outline data object. There is a special chapter called Overview that always appears as the first top-level item in the outline.
Each part supports the following properties:
||string||Unique part title.|
||array of strings||List of chapter slugs|
||string||Optional icon (defaults to 'default').|
||string||Optional Ant Icon for use in outline nav|
||string||Optional color (defaults to 'default')|
When using custom elements, make sure to place a newline between the opening/closing tags and the children. Otherwise, Markdown content may not render correctly.
Container of a single exercise.
||number / string||Unique exercise ID within chapter.|
|children||-||The contents of the exercise.|
<exercise id="1" title="Introduction"> Content goes here... </exercise>
||number / string||Unique identifier of the code exercise.|
||string||Name of the source file (without file extension).|
||string||Name of the setup file (without file extension).|
<codeblock source="part1/training-and-prediction/training" setup="part1/setup"></codeblock>
Setting up Binder
requirements.txt in the repository defines the
packages that are installed when building it with Binder. You can specify the
binder settings like repo, branch and kernel type in the
"juniper" section of
meta.json. If modifying these fields, it is recommended that you run the very
first build via the interface on the Binder website, as
this gives you a detailed build log and feedback on whether everything worked as expected.
Enter your repository URL, click "launch" and wait for it to install the dependencies
and build the image.
This guide was initially forked from the
course-starter-python template developed by Ines Montani.