Git Product home page Git Product logo

Comments (3)

runemadsen avatar runemadsen commented on September 21, 2024

Thanks for the ping @kevinstadler. This sent me down a bit of a rabbit hole, since I simply don't remember the current state of the sorting for the main processing reference. This is what I know: We have a useTree function that can sort the categories as they come in. We have an order object defined which dictates can be used in the useTree hook. But it's currently commented out, and the reference is not sorted according to that sort order on the website. This makes me think that we currently just showing the reference categories in the way it shows up in the exported JSON, which means that they are not sorted at all. This would be very easy to change, though. As far as making a sort order work for the sound library, I'm more than happy to hard code a custom sort order for you in the processing-website repo code, or we could find a way to make it easier for library maintainers to define this sort order – either in a JSON file we carry over via this script or something else. What do you think?

from processing-doclet.

kevinstadler avatar kevinstadler commented on September 21, 2024

Thanks for the swift response! Regarding the sound library ordering I'm easy in terms of whatever works.. Being able to specify a category/subcategory order object in a .json file with the other reference files would definitely transfer better to other libraries, but if that's out of scope then a hard-coded one for the sound library will certainly do.

Just following up on myself re: the second issue: I realised that generating json files for all inherited methods would open quite a can of worms, so I've been playing with selectively generating/duplicating json files instead. Below is a small shell script that I hacked together which makes copies of the superclass method files for each of the given subclasses, while also replacing the category/subcategory/classanchor fields in the files. The end goal would be to have these steps executed by the ./processingrefBuild.sh sound step, so that processing-website/content/references/translations/*/sound/ is populated accordingly.

This dumb per-file approach using sed works quite well, the only problem is that the superclass methods which are copied after the actual doclet generation obviously don't show up under the "methods": [] of the subclass json files. I could probably fudge something together to also copy over the method description into the subclass-files, but maybe you have a better/nicer idea of how this could be done..?

#!/bin/sh

cd "`dirname $0`/content/references/translations/en/sound/"
npx prettier --write .

function CopyAndReplace ()
{
	# remove class file which was only needed to trigger generation of the per-method .json files
	rm "$superclass.json"

	echo "$superclass"
	for infile in $superclass*; do
		# for every _method_.json: create a copy for very subclass
		echo " - $infile"
		for subclass in $subclasses; do
			outfile=`echo $infile | sed "s/$superclass/$subclass/"`
			if [ -f $outfile ]; then
				echo "   . $outfile already exists, subclass must have its own @webref documentation"
			else
				echo "   > $outfile"
				# change @webref (sub)categories
				if [ "$superclass" = "SoundObject" ]; then

					# fix discrepancy between class name and webref category name
					prettyclass=$subclass
					if [ "$subclass" = "Oscillator" ]; then
						prettyclass="Oscillators" # fix category name
					elif [ "$subclass" = "AudioIn" ]; then
						prettyclass="I/O"
					fi

					sed -e "s,\"category\": \"SoundObject\",\"category\": \"$prettyclass\"," \
							-e "s/\"subcategory\": \"\"/\"subcategory\": \"$subclass\"/" \
							-e "s/\"classanchor\": \"$superclass\"/\"classanchor\": \"$subclass\"/" \
								$infile > $outfile
				else
					# all concrete classes simply replace the subcategory
					sed -e "s/\"subcategory\": \"$superclass\"/\"subcategory\": \"$subclass\"/" \
							-e "s/\"classanchor\": \"$superclass\"/\"classanchor\": \"$subclass\"/" \
								$infile > $outfile
				fi
			fi
		done
		rm "$infile"
	done
	echo
}

superclass=SoundObject subclasses="AudioIn Noise Oscillator" CopyAndReplace

superclass=Oscillator subclasses="Pulse SawOsc SinOsc SqrOsc TriOsc" CopyAndReplace
superclass=Noise subclasses="BrownNoise PinkNoise WhiteNoise" CopyAndReplace
superclass=Effect subclasses="AllPass BandPass Delay HighPass LowPass Reverb" CopyAndReplace
superclass=Analyzer subclasses="Amplitude BeatDetector FFT Waveform" CopyAndReplace

cd `dirname "$0"`

from processing-doclet.

fdoflorenzano avatar fdoflorenzano commented on September 21, 2024

Hey @kevinstadler!

I went over this for a little bit, but to be honest it's a bit hard cause it's been a while and I'm not familiar with the conventions (if there are any set) that processing uses for their reference declaration. So I'm unsure whether these are special cases to take care of, or more of a general extension.

My intuition is that the current doclet script should be able to handle this more easily, since you get access to a Class' declarations and all. I don't remember getting into any inheritance stuff (cause the original doclet didn't either), but I'm guessing there should be a way of doing this with the new weblet API.

I also remember there were certain sections in the doclet that handled special cases for certain libraries, so maybe it's fine and the ClassWritter class could have a special section for these sound library cases.

from processing-doclet.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.