Skip to content

Commit

Permalink
Fix a documentation link
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 179416493
  • Loading branch information
vladmos authored and Copybara-Service committed Dec 18, 2017
1 parent 2f10da0 commit 1892677
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 10 deletions.
13 changes: 9 additions & 4 deletions src/main/java/com/google/devtools/build/docgen/DocgenConsts.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public class DocgenConsts {
public static final String SKYLARK_OVERVIEW_TEMPLATE =
"com/google/devtools/build/docgen/templates/skylark-overview.vm";

// Build Encyclopedia documentation root
// Can be overridden from SkylarkDocumentationProcessor#parseOptions
public static String BEDocsRoot = "/versions/master/be";

public static final String VAR_LEFT_PANEL = "LEFT_PANEL";

public static final String VAR_SECTION_BINARY = "SECTION_BINARY";
Expand Down Expand Up @@ -173,6 +169,15 @@ public static enum RuleType {
.put("hdrs", -90)
.build();

// The following variables are not constants as they can be overridden from
// SkylarkDocumentationProcessor#parseOptions

// Build Encyclopedia documentation root
public static String BeDocsRoot = "/versions/master/be";

// Documentation files extension
public static String documentationExtension = "html";

static String toCommandLineFormat(String cmdDoc) {
// Replace html <br> tags with line breaks
cmdDoc = cmdDoc.replaceAll("(<br>|<br[\\s]*/>)", "\n") + "\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ private static void printJavaFunctionDoc(SkylarkJavaMethodDoc method, StringBuil
private static void parseOptions(String... args) {
for (String arg : args) {
if (arg.startsWith("--be_root=")) {
DocgenConsts.BEDocsRoot = arg.split("--be_root=", 2)[1];
DocgenConsts.BeDocsRoot = arg.split("--be_root=", 2)[1];
}
if (arg.startsWith("--doc_extension=")) {
DocgenConsts.documentationExtension = arg.split("--doc_extension=", 2)[1];
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public String getName() {

@Override
public String getDocumentation() {
return annotation.doc();
return SkylarkDocUtils.substituteVariables(annotation.doc());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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.

package com.google.devtools.build.docgen.skylark;

import com.google.devtools.build.docgen.DocgenConsts;

/** A utility class for the documentation generator. */
public final class SkylarkDocUtils {
private SkylarkDocUtils() {}

/**
* Substitute special variables in the documentation with their actual values
*
* @return a string with substituted variables
*/
static String substituteVariables(String documentation) {
return documentation
.replace("$BE_ROOT", DocgenConsts.BeDocsRoot)
.replace("$DOC_EXT", DocgenConsts.documentationExtension);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.
package com.google.devtools.build.docgen.skylark;

import com.google.devtools.build.docgen.DocgenConsts;
import com.google.devtools.build.lib.skylarkinterface.Param;
import com.google.devtools.build.lib.skylarkinterface.ParamType;

Expand Down Expand Up @@ -74,6 +73,6 @@ public SkylarkMethodDoc getMethod() {

@Override
public String getDocumentation() {
return param.doc().replace("$BE_ROOT", DocgenConsts.BEDocsRoot);
return SkylarkDocUtils.substituteVariables(param.doc());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ public Descriptor invoke(
+ "referred to by the label. "
+ "It is the only way to specify a dependency to another target. "
+ "If you need a dependency that the user cannot overwrite, "
+ "<a href=\"../rules.html#private-attributes\">make the attribute private</a>.",
+ "<a href=\"../rules.$DOC_EXT#private-attributes\">make the attribute private</a>.",
objectType = SkylarkAttr.class,
returnType = Descriptor.class,
parameters = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ public Object getDefault(AttributeMap rule) {
+ "Instantiate this provider with <br>"
+ "<pre class=language-python>"
+ "OutputGroupInfo(group1 = &lt;files&gt;, group2 = &lt;files&gt;...)</pre>"
+ "See <a href=\"../rules.html#output-groups\">Output Groups</a> for more information"
+ "See <a href=\"../rules.$DOC_EXT#output-groups\">Output Groups</a> "
+ "for more information."
)
private static final Provider outputGroupInfo = OutputGroupInfo.SKYLARK_CONSTRUCTOR;

Expand Down

0 comments on commit 1892677

Please sign in to comment.