1515# You should have received a copy of the GNU General Public License
1616# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717# -----------------------------------------------------------------------------
18- '''An extension providing pygments lexers for the Cylc flow.cylc language.
18+ from pathlib import Path
19+ from cylc .sphinx_ext .cylc_lang .autodocumenters import (
20+ CylcAutoDirective ,
21+ CylcAutoTypeDirective ,
22+ CylcWorkflowDirective ,
23+ CylcGlobalDirective ,
24+ )
25+ from cylc .sphinx_ext .cylc_lang .domains import (
26+ ParsecDomain ,
27+ CylcDomain ,
28+ CylcScopeDirective
29+ )
30+ from cylc .sphinx_ext .cylc_lang .lexers import CylcLexer , CylcGraphLexer
31+
32+
33+ rawdoc1 = '''An extension providing pygments lexers for the Cylc flow.cylc
34+ language.
1935
2036
2137Pygments Lexers
165181 cylc.flow.parsec.validate.ParsecValidator.V_TYPE_HELP
166182 cylc.flow.parsec.validate.CylcConfigValidator.V_TYPE_HELP
167183
184+ '''
168185
186+ rawdoc3 = '''
169187Directives
170188----------
171189
189207
190208 This resets it to the hardcoded default which is ``flow.cylc``.
191209
210+
211+
192212'''
193213
194- from cylc .sphinx_ext .cylc_lang .autodocumenters import (
195- CylcAutoDirective ,
196- CylcAutoTypeDirective
197- )
198- from cylc .sphinx_ext .cylc_lang .domains import (
199- ParsecDomain ,
200- CylcDomain ,
201- CylcScopeDirective
202- )
203- from cylc .sphinx_ext .cylc_lang .lexers import CylcLexer , CylcGraphLexer
214+ rawdoc2 = """
215+ .. rst:directive:: .. auto-global-cylc:: source
216+
217+ Get a Cylc Global Configuration and render metadata fields.
218+
219+ If the optional source argument is give,
220+ set ``CYLC_SITE_CONF_PATH`` to this value.
221+
222+ .. note::
223+
224+ If you have a user config this will still override the site
225+ config!
226+
227+ .. rst-example::
228+
229+ .. auto-cylc-global:: {workflow_path}
230+ :show:
231+ foo,
232+ install target,
233+ bar,
234+ qax
235+
236+ .. rst:directive:: .. auto-cylc-workflow:: source
204237
238+ Get a Cylc Workflow Configuration from source and document the settings.
239+
240+ .. rst-example::
241+
242+ .. auto-cylc-workflow:: {workflow_path}/workflow
243+ :show:
244+ foo,
245+ platform
246+ """
247+
248+
249+ workflow_path = Path (__file__ ).parent .parent .parent .parent / 'etc'
250+ __doc__ = (
251+ rawdoc1
252+ + rawdoc2 .format (workflow_path = workflow_path )
253+ + rawdoc3
254+ )
205255
206256__all__ = [
207257 'CylcAutoDirective' ,
@@ -222,5 +272,7 @@ def setup(app):
222272 app .add_domain (ParsecDomain )
223273 app .add_directive ('auto-cylc-conf' , CylcAutoDirective )
224274 app .add_directive ('auto-cylc-type' , CylcAutoTypeDirective )
275+ app .add_directive ('auto-cylc-workflow' , CylcWorkflowDirective )
276+ app .add_directive ('auto-cylc-global' , CylcGlobalDirective )
225277 app .add_directive ('cylc-scope' , CylcScopeDirective )
226278 return {'version' : __version__ , 'parallel_read_safe' : True }
0 commit comments