Fix docstring escaping.
Change-Id: Ib8c8658795c9e2b0fa1a9321d7cbdef7ad4f2745
This commit is contained in:
parent
44926efd85
commit
82e55cd560
|
@ -33,7 +33,7 @@ func testCreate(t test.Tester) {
|
||||||
{
|
{
|
||||||
in: &dto.MetricFamily{
|
in: &dto.MetricFamily{
|
||||||
Name: proto.String("name"),
|
Name: proto.String("name"),
|
||||||
Help: proto.String("doc string"),
|
Help: proto.String("two-line\n doc string"),
|
||||||
Type: dto.MetricType_COUNTER.Enum(),
|
Type: dto.MetricType_COUNTER.Enum(),
|
||||||
Metric: []*dto.Metric{
|
Metric: []*dto.Metric{
|
||||||
&dto.Metric{
|
&dto.Metric{
|
||||||
|
@ -69,7 +69,7 @@ func testCreate(t test.Tester) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
out: `# HELP name doc string
|
out: `# HELP name two-line\n doc string
|
||||||
# TYPE name counter
|
# TYPE name counter
|
||||||
name{labelname="val1",basename="basevalue"} NaN
|
name{labelname="val1",basename="basevalue"} NaN
|
||||||
name{labelname="val2",basename="basevalue"} 0.23 1234567890
|
name{labelname="val2",basename="basevalue"} 0.23 1234567890
|
||||||
|
|
|
@ -422,7 +422,9 @@ func (p *Parser) readingHelp() stateFn {
|
||||||
if p.readTokenUntilNewline(); p.err != nil {
|
if p.readTokenUntilNewline(); p.err != nil {
|
||||||
return nil // Unexpected end of input.
|
return nil // Unexpected end of input.
|
||||||
}
|
}
|
||||||
p.currentMF.Help = proto.String(p.currentToken.String())
|
p.currentMF.Help = proto.String(
|
||||||
|
strings.Replace(p.currentToken.String(), `\n`, "\n", -1),
|
||||||
|
)
|
||||||
return p.startOfLine
|
return p.startOfLine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ no_labels{} 3
|
||||||
# TYPE name counter
|
# TYPE name counter
|
||||||
name{labelname="val1",basename="basevalue"} NaN
|
name{labelname="val1",basename="basevalue"} NaN
|
||||||
name {labelname="val2",basename="base\"v\\al\nue"} 0.23 1234567890
|
name {labelname="val2",basename="base\"v\\al\nue"} 0.23 1234567890
|
||||||
# HELP name doc string
|
# HELP name two-line\n doc string
|
||||||
|
|
||||||
# HELP name2 doc string 2
|
# HELP name2 doc string 2
|
||||||
# TYPE name2 gauge
|
# TYPE name2 gauge
|
||||||
|
@ -101,7 +101,7 @@ name2{ labelname = "val1" }-Inf
|
||||||
out: []*dto.MetricFamily{
|
out: []*dto.MetricFamily{
|
||||||
&dto.MetricFamily{
|
&dto.MetricFamily{
|
||||||
Name: proto.String("name"),
|
Name: proto.String("name"),
|
||||||
Help: proto.String("doc string"),
|
Help: proto.String("two-line\n doc string"),
|
||||||
Type: dto.MetricType_COUNTER.Enum(),
|
Type: dto.MetricType_COUNTER.Enum(),
|
||||||
Metric: []*dto.Metric{
|
Metric: []*dto.Metric{
|
||||||
&dto.Metric{
|
&dto.Metric{
|
||||||
|
|
Loading…
Reference in New Issue