Fixing duplicate label issue.

For projects that have multiple APIs documented simultaneously, if
the labels are the equal on more than one version of the API build
will fail due to duplicate label.
Adding a random number to minimize the chance of duplicate label.

Change-Id: Ic8434ce79630637a878fa64307796be0f3efe6d1
This commit is contained in:
Telles Nobrega 2018-12-11 10:35:32 -03:00
parent 4fdeb69a5b
commit b23ce2f788
1 changed files with 3 additions and 1 deletions

View File

@ -12,6 +12,7 @@
from collections import OrderedDict
import os
import random
import re
from docutils import nodes
@ -198,7 +199,8 @@ class RestMethodDirective(rst.Directive):
# We need to build a temporary target that we can replace
# later in the processing to get the TOC to resolve correctly.
temp_target = "%s-selector" % node['target']
temp_target = "%s-%d-selector" % (node['target'],
random.randint(1, 1000))
target = nodes.target(ids=[temp_target])
self.state.add_target(temp_target, '', target, lineno)
section += node