Giter Site home page Giter Site logo

dwtj / dwtj_rules_markdown Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 3.0 106 KB

Lint Markdown files in your Bazel workspace

Home Page: https://dwtj.github.io/dwtj_rules_markdown/

License: MIT License

Starlark 100.00%
bazel-rule bazel-aspects markdown markdownlint

dwtj_rules_markdown's People

Contributors

dwtj avatar

Stargazers

 avatar

Watchers

 avatar  avatar

dwtj_rules_markdown's Issues

`local_markdownlint_external_repository` fails if `name` attribute is not `local_markdownlint`

Currently, the README.md suggests synthesizing a markdownlint toolchain like this:

local_markdownlint_external_repository(
    name = 'local_markdownlint',
)

I haven't tested it yet, but from looking at the code, I suspect that it will fail ungracefully if the user sets any name besides local_markdownlint. At least one problem would come from here

def register_local_markdownlint_toolchain():
native.register_toolchains("@local_markdownlint//:toolchain")

because it uses a hard-coded local_markdownlint.

I think that this issue should be resolved in one of two ways:

  • Fix this case where the user uses a different name attribute.
  • Remove this repository rule from the public API and instead define a 0-arity macro which just invokes the repository rule with this hard-coded name.

How to create a toolchain that uses markdownlint from bazel

I tried this:

load("@dwtj_rules_markdown//markdown:toolchains.bzl", "markdownlint_toolchain")
markdownlint_toolchain(
    name = "mdlint_toolchain_instance",
    node_executable = "@nodejs//:node",
    markdownlint_executable = "@npm//markdownlint-cli/bin:markdownlint.sh",
    config = "//:.markdownlint.json",
)

toolchain(
    name = "mdlint_toolchain",
    toolchain = ":mdlint_toolchain_instance",
    toolchain_type = "@dwtj_rules_markdown//markdown/toolchains/markdownlint:toolchain_type",
    visibility = ["//visibility:public"],
)

But it seems that what is passed to markdownlint_executable is passed as an argument to the node_executable, which seems weird, it is executable on its own. (I can pass the markdownlint.js file, and that runs, but then it can't find its dependencies)

`markdownlint_aspect` emits actions which fail if selected `markdownlint_toolchain` doesn't have explicitly defined config file

The project README currently recommends that a client Bazel project should add something like this to their WORKSPACE file:

DWTJ_RULES_MARKDOWN_COMMIT = "c555fe9dca1782c123ec8eda1fdba11345e9e5e7"
DWTJ_RULES_MARKDOWN_SHA256 = "f5ed694d7a3998e68f2d3648263e59d8dfd5a815f985909c343a94f6c534ed10"

http_archive(
    name = "dwtj_rules_markdown",
    sha256 = DWTJ_RULES_MARKDOWN_SHA256,
    strip_prefix = "dwtj_rules_markdown-{}".format(DWTJ_RULES_MARKDOWN_COMMIT),
    url = "https://github.com/dwtj/dwtj_rules_markdown/archive/{}.zip".format(DWTJ_RULES_MARKDOWN_COMMIT),
)

load("@dwtj_rules_markdown//markdown:defs.bzl", "local_markdownlint_external_repository")

local_markdownlint_external_repository(
    name = 'local_markdownlint',
)

load('@local_markdownlint//:defs.bzl', 'register_local_markdownlint_toolchain')

register_local_markdownlint_toolchain()

However, builds with such a WORKSPACE currently fail because of a bug:

ERROR: /home/dwtj/Projects/PhasicJ/BUILD:3:17: //:markdown: missing input file 'external/local_markdownlint/markdownlint_config.json', owner: '@local_markdownlint//:markdownlint_config.json'
ERROR: /home/dwtj/Projects/PhasicJ/BUILD:3:17 1 input file(s) do not exist

As a workaround, the user can specify a config file explicitly. For example,

local_markdownlint_external_repository(
    name = 'local_markdownlint',
    config = '//:.markdownlint.json'
)

Invalid aspect documentation

The readme says

build --aspects @dwtj_rules_markdown//markdown:aspects.bzl%markdownlint_aspect

but the example shows it has to be

build --aspects @dwtj_rules_markdown//markdown:defs.bzl%markdownlint_aspect

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.