Custom docstring format

40 views
Skip to first unread message

Johannes Luther

unread,
Mar 18, 2022, 6:07:46 AM3/18/22
to sphinx-users
Hi sphinx-users,
maybe I have a weird requirements or more like a question whether the following is possible using sphinx.
I'm using Python code to define testcases using a predefined testing framework (pyATS).

So within this framework, test cases are defined as Python classes with multiple test steps as methods within this class. Example

class myTestCase1(aetest.Testcase):
  @aetest.test
  def myTestStep1(self):
     #... Test code
  @aetest.test
  def myTestStep2(self):
     #... Test code
class myTestCase2(aetest.Testcase):
# ...

So I don't really need to document classes in the usual way, because there are no arguments etc. It's more like a container class.

What I like to achive is a "human readable" Test Case documentation from the code.
If using the example from above:
class myTestCase1(aetest.Testcase):
  ''' myTestCase1
  :test-purpose: The purpose of this test is to check whether spiderman is cool.
  :test-environment: Please refer to <LINK>
  :test-description: Ask 100 people if spiderman is cool
  :test-expected-results: At least 51 people think that spiderman is cool
  '''
  @aetest.test
  def myTestStep1(self):
     #... Test code
  @aetest.test
  def myTestStep2(self):
     #... Test code
class myTestCase2(aetest.Testcase):
# ...

Hope you get the point... So I want to generate a document (preferably a markdown document) based on a jinja2 template, where I can access the definitions from above like :test-description:

Is something like this achivable using sphinx?
Message has been deleted

Komiya Takeshi

unread,
Mar 19, 2022, 12:45:52 PM3/19/22
to sphinx...@googlegroups.com
Hi,

If you can accept writing docstring by reST, you can do it with
creating a transform component that generates content from field-list
items like "test-purpose", "test-environment", and so on.
https://docutils.sourceforge.io/docs/ref/transforms.html

Thanks,
Takeshi KOMIYA

2022年3月18日(金) 19:07 'Johannes Luther' via sphinx-users
<sphinx...@googlegroups.com>:
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/12ed5e39-e75a-4a63-801c-3475f88bc314n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages