Code Monkey home page Code Monkey logo

devcookbook's Introduction

The Cookbook for Developers!

Welcome to this open source cookbook for recipes anyone wants to share!

You can contribute a recipe by opening a pull request containing your recipe formatted in markdown following the template. For more instructions check out this guide.

If you would like to contribute an improvement to the compiler, instructions for setting up a local dev environment can be found here.

devcookbook's People

Contributors

demophoon avatar jennjin avatar livelovegeek avatar maybeanerd avatar microsoft-github-policy-service[bot] avatar normanlorrain avatar paulcam206 avatar rmtc3 avatar t-eckert avatar tashasev avatar taskul 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

devcookbook's Issues

Directions subsections cannot be parsed

First seen with pull request #5. The directions are have subheadings which cannot be parsed by the compiler.

## Directions

1. Place oven rack in the lower-middle position and preheat oven to 400°. Line a baking sheet with foil.
### Start the Squash
2. Brush or otherwise coat the squash with 2 Tbsp olive oil. Place the squash cut side down onto the prepared baking sheet and bake until easily pierced with a knife or skewer, 40-45 minutes. Proceed with the remaining steps as the squash roasts.

### Make the Breadcrumbs
(This step is optional-skip if using panko or other premade crumbs)
3. Melt 2 Tbsp butter in a large 12" skillet over medium heat. 
4. Add the cubed bread and toss to coat in the melted butter. Continue to toast the bread until golden brown and crunchy, about 10 minutes. Sprinkle generously with salt and pepper and set aside on paper towel to drain.

When the compiler is run, the following exception is raised:

Traceback (most recent call last):
  File "/home/t_eck/code/forks/DevCookbook/compile.py", line 44, in <module>
    [render_recipe_page(recipe, env) for recipe in recipes],
  File "/home/t_eck/code/forks/DevCookbook/compile.py", line 44, in <listcomp>
    [render_recipe_page(recipe, env) for recipe in recipes],
  File "/home/t_eck/code/forks/DevCookbook/recipe_compiler/render.py", line 16, in render_recipe_page
    return env.get_template("recipe.html").render(recipe=recipe)
  File "/home/t_eck/code/forks/DevCookbook/.venv/lib/python3.9/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/home/t_eck/code/forks/DevCookbook/.venv/lib/python3.9/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/home/t_eck/code/forks/DevCookbook/.venv/lib/python3.9/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/home/t_eck/code/forks/DevCookbook/recipe_compiler/templates/recipe.html", line 1, in top-level template code
    {% extends "index.html" %} {% block content %}
  File "/home/t_eck/code/forks/DevCookbook/recipe_compiler/templates/index.html", line 15, in top-level template code
    {% block content %} {% endblock content %}
  File "/home/t_eck/code/forks/DevCookbook/recipe_compiler/templates/recipe.html", line 20, in block "content"
    {% for ingredient in recipe.ingredients %}
TypeError: 'NoneType' object is not iterable

The parser should be changed to accept subheadings and display them correctly.

List collection in the parser omits sublists

Issue

When a user writes a list of ingredients or directions with a sublist, the sublist is not parsed in and is omitted in the output.

This issue was first seen in @jimbobbennett's pull request #3.

In this PR, @jimbobbennett submitted a recipe which included the instruction:

1. Whilst the condensed milk is boiling, make the pie base:

    1. Grease a pie dish with butter

    1. Put the digestive biscuits in a plastic bag and smash and roll with a rolling pin till you have fine crumbs

    1. Melt a small amount of butter in a pan and mix in the biscuit crumbs. You need enough butter for the crumbs to stick together, but not too much, so keep adding small bits of butter as needed until the crumbs start to bind.

    1. Spread the crumbs into the pie dish and press them firmly to the bottom and sides to make a pie base

    1. Put in the fridge till the butter cools and sets

The compiler did not render the indented instructions:

image

Root cause

The get_list_within_section function does not recursively collect items. It only checks the first set of children within a list and returns the strings. Source

Possible solutions

Instead of returning a list of strings, the parser should return a list of nodes which may be leafs or have children. No new class should be needed, the existing Node class in the marko package will do the job just fine.

The Recipe class will need to be changed such that the ingredients and instructions attributes are lists of Node instead of str.

The render_recipe_page will need to be changed to render HTML from the markdown nodes before being passed to the Jinja template.

Clarify the flags for compiling local versus production

Currently, when you compile using the compile.py script, you must pass in a --target flag. However, this is confusing as target commonly refers to an output directory. In this case, it refers to the relative path set for links within the site so that a user can debug the site locally and still have it work correctly when published to GitHub pages.

While the behavior of what the switch does shouldn't change, the flag to switch it should. Instead of -t/--target, a user should pass no flag to compile for local and a --prod flag to compile for GitHub pages.

Document how to contribute to the compiler

There is no documentation on how to fork and set up the repository to contribute to the compiler itself.

Add this documentation in a CONTRIBUTING.md file and link to it from the README.md.

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.