Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
Remove dependency on Bazel's build.proto.
Browse files Browse the repository at this point in the history
Fixes #4

--
MOS_MIGRATED_REVID=119722062
  • Loading branch information
davidzchen committed Apr 13, 2016
1 parent 9407f39 commit 833e33f
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 20 deletions.
28 changes: 17 additions & 11 deletions skydoc/BUILD
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package(default_visibility = ["//visibility:public"])

load("@protobuf//:protobuf.bzl", "py_proto_library")

py_proto_library(
name = "build_pb_py",
srcs = ["build.proto"],
default_runtime = "@protobuf//:protobuf_python",
protoc = "@protobuf//:protoc",
)

py_library(
name = "common",
srcs = ["common.py"],
deps = [
"@bazel_tools//src/main/protobuf:build_pb_py",
],
)

py_test(
Expand All @@ -26,8 +32,8 @@ py_test(
name = "macro_extractor_test",
srcs = ["macro_extractor_test.py"],
deps = [
":build_pb_py",
":macro_extractor",
"@bazel_tools//src/main/protobuf:build_pb_py",
],
)

Expand All @@ -44,33 +50,33 @@ py_test(
name = "rule_extractor_test",
srcs = ["rule_extractor_test.py"],
deps = [
":build_pb_py",
":rule_extractor",
"@bazel_tools//src/main/protobuf:build_pb_py",
],
)

py_library(
name = "rule",
srcs = ["rule.py"],
deps = [
":build_pb_py",
"//external:mistune",
"@bazel_tools//src/main/protobuf:build_pb_py",
],
)

py_binary(
name = "skydoc",
srcs = ["main.py"],
data = [
"//skydoc/sass:main.css",
"//skydoc/templates",
],
main = "main.py",
deps = [
":macro_extractor",
":rule",
":rule_extractor",
"//external:jinja2",
"//external:gflags",
],
data = [
"//skydoc/templates",
"//skydoc/sass:main.css",
"//external:jinja2",
],
)
89 changes: 89 additions & 0 deletions skydoc/build.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright 2014 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto2";

package skydoc;

message Attribute {
// Indicates the type of attribute.
enum Discriminator {
INTEGER = 1; // int_value
STRING = 2; // string_value
LABEL = 3; // string_value
OUTPUT = 4; // string_value
STRING_LIST = 5; // string_list_value
LABEL_LIST = 6; // string_list_value
OUTPUT_LIST = 7; // string_list_value
DISTRIBUTION_SET = 8; // string_list_value - order is unimportant
LICENSE = 9; // license
STRING_DICT = 10; // string_dict_value
FILESET_ENTRY_LIST = 11; // fileset_list_value
LABEL_LIST_DICT = 12; // label_list_dict_value
STRING_LIST_DICT = 13; // string_list_dict_value
BOOLEAN = 14; // int, bool and string value
TRISTATE = 15; // tristate, int and string value
INTEGER_LIST = 16; // int_list_value
STRING_DICT_UNARY = 17; // string_dict_unary_value
UNKNOWN = 18; // unknown type, use only for build extensions
LABEL_DICT_UNARY = 19; // label_dict_unary_value
SELECTOR_LIST = 20; // selector_list
NAME = 21; // name, use only for the name attribute
}
}

// Information about allowed rule classes for a specific attribute of a rule.
message AllowedRuleClassInfo {
enum AllowedRuleClasses {
ANY = 1; // Any rule is allowed to be in this attribute
SPECIFIED = 2; // Only the explicitly listed rules are allowed
}

required AllowedRuleClasses policy = 1;

// Rule class names of rules allowed in this attribute, e.g "cc_library",
// "py_binary". Only present if the allowed_rule_classes field is set to
// SPECIFIED.
repeated string allowed_rule_class = 2;
}

// This message represents a single attribute of a single rule.
message AttributeDefinition {

// Rule name, e.g. "cc_library"
required string name = 1;
required Attribute.Discriminator type = 2;
required bool mandatory = 3;

// Only present for attributes of type LABEL and LABEL_LIST.
optional AllowedRuleClassInfo allowed_rule_classes = 4;

optional string documentation = 5;
}

message RuleDefinition {
required string name = 1;
// Only contains documented attributes
repeated AttributeDefinition attribute = 2;

optional string documentation = 3;

optional string example_documentation = 4;

}

message BuildLanguage {
// Only contains documented rule definitions
repeated RuleDefinition rule = 1;
}
1 change: 0 additions & 1 deletion skydoc/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""Common functions for skydoc."""

import re
from src.main.protobuf import build_pb2
from xml.sax.saxutils import escape


Expand Down
2 changes: 1 addition & 1 deletion skydoc/macro_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import ast

from src.main.protobuf import build_pb2
from skydoc import build_pb2
from skydoc import common

def get_type(expr):
Expand Down
2 changes: 1 addition & 1 deletion skydoc/macro_extractor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import textwrap
import unittest
from google.protobuf import text_format
from skydoc import build_pb2
from skydoc import macro_extractor
from src.main.protobuf import build_pb2


class MacroExtractorTest(unittest.TestCase):
Expand Down
1 change: 0 additions & 1 deletion skydoc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from skydoc import macro_extractor
from skydoc import rule
from skydoc import rule_extractor
from src.main.protobuf import build_pb2

gflags.DEFINE_string('output_dir', '',
'The directory to write the output generated documentation to if '
Expand Down
2 changes: 1 addition & 1 deletion skydoc/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Representations used for rendering documentation templates."""

import mistune
from src.main.protobuf import build_pb2
from skydoc import build_pb2

class Attribute(object):
"""Representation of an attribute used to render documentation templates."""
Expand Down
2 changes: 1 addition & 1 deletion skydoc/rule_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import ast

from src.main.protobuf import build_pb2
from skydoc import build_pb2
from skydoc import common
from skydoc.stubs import attr
from skydoc.stubs import skylark_globals
Expand Down
2 changes: 1 addition & 1 deletion skydoc/rule_extractor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import tempfile
import textwrap
from google.protobuf import text_format
from skydoc import build_pb2
from skydoc import rule_extractor
from src.main.protobuf import build_pb2


class RuleExtractorTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion skydoc/stubs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ py_library(
"skylark_globals.py",
],
deps = [
"@bazel_tools//src/main/protobuf:build_pb_py",
"//skydoc:build_pb_py",
],
)
2 changes: 1 addition & 1 deletion skydoc/stubs/attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from src.main.protobuf import build_pb2
from skydoc import build_pb2

def strcmp(s1, s2):
if s1 > s2:
Expand Down

0 comments on commit 833e33f

Please sign in to comment.