Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# Support #550

Merged
merged 3 commits into from
Aug 19, 2020
Merged

C# Support #550

merged 3 commits into from
Aug 19, 2020

Conversation

rogerbarton
Copy link
Contributor

@rogerbarton rogerbarton commented Jul 3, 2020

Hi thanks for this amazing tool! I'm working on a C#/C++ Unity project and wanted some good docs so decided to use this.
I've added basic C# support via the sphinx-csharp package, which is a simple C# domain. I have also made several modifications there, see djungelorm/sphinx-csharp#8

I have got it to work quite well already, have a look here.

It was initially based it on the php domain PR #351, so it's also done as a optional part.

You can use these pip requirements.txt

git+https://github.com/rogerbarton/sphinx-csharp.git
git+https://github.com/rogerbarton/breathe.git@dev

Note: I'm still working on this, and there are some things that need to be fixed. Some parts related to the version/dependencies will be removed hopefully. Also fyi I haven't done much py/sphinx stuff yet.

breathe/renderer/sphinxrenderer.py Show resolved Hide resolved
breathe/renderer/sphinxrenderer.py Show resolved Hide resolved
breathe/renderer/sphinxrenderer.py Outdated Show resolved Hide resolved
@rogerbarton rogerbarton marked this pull request as ready for review July 4, 2020 19:10
@cadop
Copy link

cadop commented Jul 30, 2020

is this going to be merged?

@rogerbarton
Copy link
Contributor Author

rogerbarton commented Aug 12, 2020

I've been using it successfully for a while now, for me its in a stable state. The complexity is really inside the c# domain, for breathe its reasonably trivial.

@vermeeren vermeeren self-assigned this Aug 19, 2020
@vermeeren vermeeren self-requested a review August 19, 2020 19:42
@vermeeren vermeeren added the enhancement Improvements, additions (also cosmetics) label Aug 19, 2020
@vermeeren vermeeren merged commit d762cfa into breathe-doc:master Aug 19, 2020
vermeeren added a commit that referenced this pull request Aug 19, 2020
@vermeeren
Copy link
Collaborator

@rogerbarton Thanks a lot for the patches and the patience!

@vermeeren vermeeren linked an issue Aug 19, 2020 that may be closed by this pull request
@vermeeren
Copy link
Collaborator

Just released v4.20.0 containing this among other things, fyi.

sredmond added a commit to hedronvision/hedron-docs that referenced this pull request Dec 11, 2020
…gration.

This project depends on a few external dependencies:

- Sphinx, to drive the whole documentation process.
- Breathe, to parse doxygen's XML output.
- Exhale, to build autogenerated documentation using breathe's directives.
- A C# domain extension, which tells Sphinx how to render C# elements.

To support our admittedly odd use case, I patch breathe (at [1]) and exhale (at
[2]). I've also been developing [3] on top of djungelorm's `sphinx_csharp` repo
[4], since it only supports a subset of C#, and doesn't cover some of our uses.

However, in the meanwhile, rogerbarton forked and developed off of the old C#
extension [5], and merged a change into breathe [6] using djungelorm's interface
rather than a sphinxcontrib namespace package. In [6] it's linked against the
package from his repository, since djungelorm still holds the PyPI package.

Furthermore, even rogerbarton's quality extension of sphinx_csharp doesn't
support the subset of C# we are using (including some properties), so we have to
comment out a piece of the `Size2D` example struct.

This is all to say that the dependencies are currently wonky, although we'll
eventually be able to depend just on my forks, and one day on just the normal
breathe/exhale if they can incorporate any useful new changes.

This project also depends on `doxygen`, which isn't a Python package, but rather
an external binary. Here's hoping it exists on the build servers.

The `requirements.txt` file includes a few custom HTML themes, just for variety.

[1]: https://github.com/sredmond/breathe
[2]: https://github.com/sredmond/exhale
[3]: https://github.com/sredmond/sphinxcontrib-csharpdomain
[4]: https://github.com/djungelorm/sphinx-csharp
[5]: https://github.com/rogerbarton/sphinx-csharp
[6]: breathe-doc/breathe#550
@bvarba
Copy link

bvarba commented Jan 14, 2021

Hi guys, looks like awesome work here! I'm trying to use Breathe for a c# project that has xml output. I have included extensions['breathe'] in conf.py
I am getting this error:
Running Sphinx v3.4.3

Exception occurred:
File "/home/[user]/.local/lib/python3.6/site-packages/breathe/renderer/sphinxrenderer.py", line 155, in
class CSharpNamespacePlain(BaseObject, cs.CSharpNamespacePlain):
AttributeError: module 'sphinx_csharp.csharp' has no attribute 'CSharpNamespacePlain'
The full traceback has been saved in /tmp/sphinx-err-ftxjyzb1.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at https://github.com/sphinx-doc/sphinx/issues. Thanks!
Makefile:20: recipe for target 'html' failed
make: *** [html] Error 2

Any suggestions?
to mention I have installed breath through pip3 and also tried installing sphinx-csharp, not sure if i need to. Also tried including in conf.py extensions, same error.

@rogerbarton
Copy link
Contributor Author

Using pip install sphinx-csharp will currently not work as djungelorm/sphinx-csharp#8 has not been merged yet (due to inactive developer).

You should use this for now:

pip install git+https://github.com/rogerbarton/sphinx-csharp.git

Hope this fixes it

@bvarba
Copy link

bvarba commented Jan 14, 2021

Awesome, thanks @rogerbarton!
Just tried and works better :)
I am getting this now:Running Sphinx v3.4.3
WARNING: while setting up extension sphinx_csharp.csharp: extension 'sphinx_csharp.csharp' has no setup() function; is it really a Sphinx extension module?
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 3 source files that are out of date
updating environment: [new config] 3 added, 0 changed, 0 removed
/home/[user]/.local/lib/python3.6/site-packages/recommonmark/parser.py:75: UserWarning: Container node skipped: type=document
warn("Container node skipped: type={0}".format(mdnode.t))
reading sources... [100%] index
Exception occurred:
File "/home/[user]/.local/lib/python3.6/site-packages/sphinx_csharp/csharp.py", line 309, in add_target_and_index
objects = self.env.domaindata['cs']['objects']
KeyError: 'cs'
The full traceback has been saved in /tmp/sphinx-err-2egbkvyq.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at https://github.com/sphinx-doc/sphinx/issues. Thanks!
Makefile:20: recipe for target 'html' failed
make: *** [html] Error 2

Something I am missing?

@rogerbarton
Copy link
Contributor Author

rogerbarton commented Jan 14, 2021

Hmm, did you use extensions = [... 'sphinx_csharp'] in your conf.py. It seems like you might have accidentally added a .csharp there.

Maybe have a look at how its done here: https://github.com/rogerbarton/vr-modeling/blob/master/conf.py

@bvarba
Copy link

bvarba commented Jan 14, 2021

you are right I had added sphinx_csharp.csharp instead. It works now! Thanks for your work, much appreciated!

@Feng-Seng
Copy link

Hi @rogerbarton rogerbarton,

I am trying your solution and have some warning and exception, do you have any thought about this?


WARNING: Method signature invalid: static inline void Error (string s)
WARNING: Method signature invalid: static inline void Warning (string s)
WARNING: Method signature invalid: static inline void Log (string s)
WARNING: Method signature invalid: static inline Dictionary< ESkeletonType, Dictionary< ESkinPart, List< string > > > initAssetMaps ()
WARNING: Method signature invalid: static inline Dictionary< ESkinPart,(List< string >, List< string >)> initAssetMap2 ()
WARNING: Method signature invalid: static inline ESkeletonType getSkeletonTypeByName (string name)
WARNING: Method signature invalid: static inline ESkinPart getSkinPartByName (string name)
WARNING: Method signature invalid: static inline error _cloneSkinMesh (GameObject src, GameObject target)
WARNING: Method signature invalid: static inline async Task< bool > AutoInitAssetBundleSource ()
WARNING: Method signature invalid: static inline Task< bool > _initAssetBundle (AssetBundleSouce src)
WARNING: Method signature invalid: static inline async Task<(Object, error)> LoadAssetEx (string assetKeyName, AssetBundleSouce assetSource)
WARNING: Method signature invalid: static inline async Task<(Object, error)> LoadAsset (string assetKeyName)
WARNING: Method signature invalid: inline void SaveTextureFile (string path)
WARNING: Method signature invalid: static inline Transform rotateAnchor (Transform rootBone)
WARNING: .....
...... many warnings like those .....

Exception:
File "/opt/homebrew/lib/python3.9/site-packages/sphinx_csharp/csharp.py", line 237, in parse_type_signature
match = CLASS_SIG_RE.match(sig.strip())
AttributeError: 'NoneType' object has no attribute 'strip'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements, additions (also cosmetics)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

import breathe in setup.py Cannot get property type from c# doxygen generated (C# support in general)
6 participants