Skip to content
Snippets Groups Projects
Commit 76dcf0e7 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Implement @localdoc tag.

parent b4e18797
Branches
Tags
No related merge requests found
require "jsduck/tag/tag"
require 'jsduck/format/shortener'
module JsDuck::Tag
# Non-inheritable documentation
class Localdoc < Tag
def initialize
@pattern = "localdoc"
@tagname = :localdoc
@html_position = POS_LOCALDOC
end
def parse_doc(p, pos)
{
:tagname => :localdoc,
:doc => :multiline,
}
end
def process_doc(m, tags, pos)
m[:localdoc] = tags.map {|t| t[:doc] }.join("\n\n")
end
def format(m, formatter)
m[:localdoc] = formatter.format(m[:localdoc])
end
def to_html(m)
m[:localdoc]
end
end
end
......@@ -171,17 +171,18 @@ module JsDuck::Tag
POS_ASIDE = 1
POS_PRIVATE = 2
POS_DOC = 3
POS_DEFAULT = 4
POS_SINCE = 5
POS_DEPRECATED = 6
POS_ENUM = 7
POS_TEMPLATE = 8
POS_PREVENTABLE = 9
POS_PARAM = 10
POS_SUBPROPERTIES = 11
POS_RETURN = 12
POS_THROWS = 13
POS_OVERRIDES = 14
POS_LOCALDOC = 4
POS_DEFAULT = 5
POS_SINCE = 6
POS_DEPRECATED = 7
POS_ENUM = 8
POS_TEMPLATE = 9
POS_PREVENTABLE = 10
POS_PARAM = 11
POS_SUBPROPERTIES = 12
POS_RETURN = 13
POS_THROWS = 14
POS_OVERRIDES = 15
# Called before #to_html to allow rendering of Markdown content.
# For this an instance of DocFormatter is passed in, on which one
......
require "mini_parser"
describe JsDuck::Aggregator do
def parse(string)
Helper::MiniParser.parse(string, {:inherit_doc => true})
end
describe "Inheriting from parent with @localdoc" do
let(:cls) do
@docs = parse(<<-EOF)
/**
* @class Parent
* Parent docs.
* @localdoc Parent-specific docs.
*/
/**
* @class Child
* @extend Parent
* @inheritdoc
*/
EOF
@docs["Child"]
end
it "inherits :doc" do
cls[:doc].should == "Parent docs."
end
it "doesn't inherit @localdoc" do
cls[:localdoc].should == nil
end
end
describe "Inheriting while having @localdoc in both parent and child" do
let(:cls) do
@docs = parse(<<-EOF)
/**
* @class Parent
* Parent docs.
* @localdoc Parent-specific docs.
*/
/**
* @class Child
* @extend Parent
* @inheritdoc
* @localdoc Child-specific docs.
*/
EOF
@docs["Child"]
end
it "inherits :doc" do
cls[:doc].should == "Parent docs."
end
it "keeps local @localdoc" do
cls[:localdoc].should == "Child-specific docs."
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment